I use gnuplot a lot for visualizing data.
One shouldn't consider it a tool just for mathematicians etc.
I present a few examples here for interacting with gnuplot
directly from the command line. You should be able to
past any of these into any linux terminal.
One can get gnuplot to output directly to the terminal like:
echo "set term dumb; plot sin(x)" | gnuplot
But that isn't generally very useful, and instead one can
output to a seperate X window from a terminal emulator like:
echo 'plot exp(-x**2) with boxes' | gnuplot -persist
Getting a little more complex, one can specify the x range,
like in the following example to plot the FastE packet rate vs Size:
echo 'pad=20; plot [64:1518] (100*10**6)/((pad+x)*8)' | gnuplot -persist
And getting more complex again, one can define functions like:
echo 'set logscale y; mesh(x)=(x-1)*(x/2); plot [1:100] 2*x,x*log(x),mesh(x)' | gnuplot -persist
gnuplot 4.0 introduced support for popen, or reading directly
from system commands with the < special character.
For e.g. the following will plot file sizes:
echo "set logscale y; plot \"<find /usr/share/doc -type f -printf '%s\n'\" with dots" | gnuplot -persist
And again showing how to plot the disk usage in addition to the above:
echo "set logscale y; plot \"<find /usr/share/doc -type f -printf '%k %s\n'\" using (\$1*1024) with dots, '' using 2 with dots" | gnuplot -persist
Another example of directly plotting command output is process mem usage:
echo "plot '<ps -e -o rss=' with boxes" | gnuplot -persist
And again showing how to plot the virtual mem usage in addition:
echo "plot '<ps -e -o vsz=' with boxes fs solid, '<ps -e -o rss=' with boxes fs solid" | gnuplot -persist
Note be wary of the memory reporting from ps and top:
http://www.pixelbeat.org/scripts/ps_mem.py
For more complete gnuplot examples, showing how to
set up the axis labels and tics etc. please see:
http://www.pixelbeat.org/docs/ssia/ssia.htmlhttp://t16web.lanl.gov/Kawano/gnuplot/index-e.html
BTW, A big thank you to Lars Hecking for his work on gnuplot!
Pádraig.
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!