Difference between revisions of "Gnuplot"

From Linuxintro
imported>ThorstenStaerk
imported>ThorstenStaerk
Line 8: Line 8:
  
 
[[Image:Snapshot-gnuplot.png]]
 
[[Image:Snapshot-gnuplot.png]]
 +
 +
= xy diagrams =
 +
gnuplot> plot "csv.csv" using ($1+0):($2+0):1 with lines
  
 
= Output to a file =
 
= Output to a file =

Revision as of 20:59, 21 December 2012

Here is an example how to visualize vmstat's output using gnuplot.

vmstat 1 10 | grep -v r > vmstat.txt
gnuplot -p -e "plot 'vmstat.txt' using 13 title 'CPU user load' with lines, 'vmstat.txt' using 14 title 'CPU system load' with lines, \
'vmstat.txt' using 15 title 'CPU idle time' with lines, 'vmstat.txt' using 16 title 'CPU IO wait time' with lines"

The result will look like this:

Snapshot-gnuplot.png

xy diagrams

gnuplot> plot "csv.csv" using ($1+0):($2+0):1 with lines

Output to a file

To save your output as a .png file, add the commands below in bold:

gnuplot -p -e "plot 'datasource.txt' using 4  with lines;set output 'test.png';set terminal png;replot"

TroubleShooting

If you get an error message like

gnuplot -p -e "plot 'data.txt' with lines"
Cannot open load file '-p'
line 0: util.c: No such file or directory

You are most probably on an outdated gnuplot version. Version 4.4 differs a lot from 4.2.

See also