Generating plots with pgfplots

Plotting results is often needed in Computer Science.
Say, you have a program that generates data which you want to plot.

A normal approach to this would be:

  1. Write your results to a csv-file
  2. Importing that file into a spreadsheet application like Excel
  3. Clicking around to generate a plot
  4. Saving the plot as an image
  5. Putting the image into a LaTeX report

In case you change something in your program, this entire process would have to be repeated in order to get your fresh results plotted and into your report.

How cumbersome. This is a stupid problem we can solve with programming.
If our program already generates data and writes it to disk in text format, we can just add functions that write that data as LaTeX!
Continue reading “Generating plots with pgfplots”