Thursday, 24 October 2013

Creating pretty graphs in linux with gnuplot

You have to love graphs and their graphingawesomeness. I'm not going to lie, I have a thing for them ever since I met gnuplot.

I really should be hitting they hay so this will be a quick one.

As an example I have pinged google 100 times and dropped the delay into a text file

[adam@localhost gnuplot]$ ping google.com -c 100 -ni 0.2 | awk -F [=\ ] {'print $(NF-1)'} | grep -E "[0-9]" > ping.dat

[adam@localhost gnuplot]$ head -n 5 ping.dat
27.3
22.2
23.2
72.7
26.4

[adam@localhost gnuplot]$ cat ping.gp
#!/usr/bin/gnuplot
set terminal png
set output "ping.png"
set ylabel "Delay (m/s)"
set xlabel "Number"
plot "ping.dat" with lines

[adam@localhost gnuplot]$ ./ping.gp




Poof. we have a graph



Not cool enough for you?

- set terminal png
- set output "ping.png"
+ set terminal dumb




1 comment: