Tag Archive for 'gnuplot'

Gnuplot : how to plot graphs from any UNIX machine

gnuplot is a plotting tool that I discovered in the 90s while being a student. The binary itself is around 1.2 MB only! People often forget about it and would rather use a spreadsheet program. Granted, a spreadsheet will probably give you prettier graphs but gnuplot is very handy to graph in an automated manner, with a very small footprint.

Let’s say you have a file containing measures like this (first column is the measure point, the second column contains the measured values):

bash-3.2$ more toto
1 4
2 6
3 8
4 7
5 12
6 5
7 9
8 3

Then to draw it, just fire gnuplot and type:

gnuplot> plot ‘./toto’ using 1:2 with lines;

And bang, you get this:

gnuplot simple example

1:2 means columns 1 and 2 and “with lines” means that you will use a line to join the points (there are plenty f options such as boxes, vectors, etc.).

You can also improve things a little by creating a command file containing this for instance:

set xlabel "The title of the X Axis"
set ylabel "The title of the y Axis"
set xrange [1:8]
set yrange [0:14]
plot './toto' using 1:2 with lines 4;

And execute:

gnuplot < commandfile

You will get this:

gnuplot better exampleThese are just tiny examples but by using command files, you can automate the generation of graphs very easily.

gnuplot has tons of options and is capable of much much more, checkout the official page!

For these examples, I have used the version of gnuplot provided my macports.