Plotting With Gnuplot

by bitznbitez

For a blast from the past here is a quick tutorial on how to plot with Gnuplot.    Most plotting I do uses either an Excel spreadsheet, or Tableau, or something along those lines.   However on linux I use Open Office as my spreadsheet, and getting a copy of the chart as an image file is cumbersome.     So I am reverting to Gnuplot.

Lets say you have a data file that looks like this.    This was created via a simple cut-n-paste of data from the spreadsheet which I have saved in file bm1.dat.

#Threads Orders_Per_Minute Orders_Per_Thread_Per_Minute
1.0 5900.0 5900.0
5.0 15500.0 3100.0
10.0 29000.0 2900.0
20.0 55000.0 2750.0
50.0 98000.0 1960.0
75.0 101000.0 1346.7

To produce a gif image run gnuplot and do the following.

gnuplot> set xlabel "Total Threads"
gnuplot> set ylabel "Transactions / Minute"
gnuplot> set terminal gif size 500,400
Terminal type set to 'gif'
Options are 'nocrop font /usr/share/fonts/truetype/ttf-liberation/LiberationSans-Regular.ttf 12 size 500,400 '
gnuplot> set output 'bm1.gif'
gnuplot> plot 'bm1.dat' using 1:2 ti "Total Thruput" with linespoints

Now you will have an output file bm1.gif which looks just like the one below.

This shows the diminishing returns as the number of concurrent threads throwing data at my postgres instance exceeds fifty.

Now I might want to plot the second column, throughput per thread, in a different chart.   This is done as follows

gnuplot> set output 'bm1a.gif'
gnuplot> plot 'bm1.dat' using 1:3 ti "Thruput Per Thread" with linespoints

This produces the following chart.

This shows that the total throughput per thread declines as I increase the number of threads.   However as the first chart demonstrates total throughput continues to climb.

For much more detailed information on using gnuplot click here.