GnuPlot is the ultimate plotting tool and very powerful which has the downside of being quite hard to use especially for new users. Hopefully this article clears things up a bit (for me at least).
Probably the most common task performed when using a plotting tool is … plotting! Here are a few examples:
Plotting a function:
gnuplot> plot f(x) = x**2, f(x)
The same as above, but giving the range to plot:
gnuplot> plot [-5:5] f(x) = x**2, f(x)
Plotting two functions in the same plot:
gnuplot> plot f(x) = x**2, g(x) = x**3, f(x), g(x)
First, generate some data:
$ ping nwl.cc | sed -un 's/.*time=\(.*\) ms/\1/p' >/tmp/data
The output looks like this:
20.8 20.7 23.2 20.2 21.0 19.3 21.2 20.9 22.6 ...
Now plot it:
gnuplot> plot '/tmp/data' with lines
File output is configured by setting a different terminal than the default
x11
for the file type to generate and setting the output
variable for
the filename:
gnuplot> set terminal png size 800,600 gnuplot> set output '/tmp/data.png'
Afterwards the output of any plot
command will be written to
/tmp/data.png in png
format.
Creating PDFs works equvalently, but the size
parameter is interpreted
differently (inches instead of pixels):
gnuplot> set terminal pdf size 8,6 gnuplot> set output '/tmp/data.pdf'
But it gets even better, latex output:
gnuplot> set terminal latex size 8,6 gnuplot> set output '/tmp/data.tex'
There are various output formats available, one may even chose between
different latex packages to use. For reference, see the output of set
terminal
without further parameters.