Gnuplot is a free cross-platform program for scientific plotting, but is also useful for generating all sorts of other graphs.
There are lots of tutorials showing how to use Gnuplot in interactive mode. However, Gnuplot can also be scripted from the command line for generating static images of graphs/plots. I usually need to graph performance data, consisting of X,Y data points. Gnuplot allows me to do this easily by passing a config file to the Gnuplot program in non-interactive mode.
Here is a sample data file (plot.data) containing x, y coordinates:
0 23 115 19 1014 1120 1830 9
Here is a sample Gnuplot config file (plot.cfg)
set term png set output "plot.png"set size 0.8,0.5set yrange [0:]set xlabel "Elapsed Time"set ylabel "Throughput (requests/sec)"plot "plot.data" using 1:2 title "" w lines
From the command line, you can run it like:
Windows:
> wgnuplot.exe plot.cfg
Unix/Linux:
$ gnuplot plot.cfg
This will create an image named "plot.png" containing the line graph:
Here is sample output of rendering a larger data set with an impulse graph and a line graph:
Now that you can run it from the CLI, it is easy to integrate with other scripts or programs.
Copyright © 2006-2008 Corey Goldberg
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.