Difference between revisions of "Gnuplot"
From Noah.org
Jump to navigationJump to searchm |
|||
Line 25: | Line 25: | ||
<pre> | <pre> | ||
+ | set data style errorlines | ||
set title "Daily clock offset\nnegative means clock runs fast" | set title "Daily clock offset\nnegative means clock runs fast" | ||
set xlabel "Date" | set xlabel "Date" | ||
Line 34: | Line 35: | ||
set grid | set grid | ||
plot "ntpdate.log" using 1:10 | plot "ntpdate.log" using 1:10 | ||
+ | </pre> | ||
+ | |||
+ | For using with `cdck` | ||
+ | <pre> | ||
+ | #!/usr/bin/env gnuplot | ||
+ | |||
+ | set data style errorlines | ||
+ | set terminal x11 | ||
+ | set grid | ||
+ | set xlabel 'Sectors (2Kb/sec)' | ||
+ | set ylabel 'Reading time (usec)' | ||
+ | set logscale y | ||
+ | |||
+ | plot 'cdck-plot.dat' with lines | ||
+ | |||
+ | pause -1 | ||
+ | </pre> | ||
+ | |||
+ | old style, depricated: | ||
+ | <pre> | ||
+ | set terminal png | ||
+ | #gif small size 640,480 | ||
+ | set title "Daily clock offset\nnegative means clock runs fast" | ||
+ | set data style fsteps | ||
+ | set xlabel "Date" | ||
+ | set timefmt "%d/%m/%y\t%H%M" | ||
+ | set yrange [ -4.6 : -4.8] | ||
+ | set xdata time | ||
+ | set xrange [ "25/06/00":"29/08/00" ] | ||
+ | set ylabel "Required offset (negative minutes fast)" | ||
+ | set format x "%d/%m" | ||
+ | #\n%H:%M" | ||
+ | set grid | ||
+ | set key left | ||
+ | plot "data.dat" using 1:10 | ||
+ | reset | ||
</pre> | </pre> |
Revision as of 05:07, 29 November 2009
I use gnuplot from time to time. I don't know it well enough to do anything fancy, but I keep it in my toolbox.
Most of the time I just want to plot some points from a data file.
One of the first tricks I do is alias "gnuplot" to "gnuplot -persist":
alias gnuplot='gnuplot -persist'
This will tell gnuplot to keep an image displayed on the screen. By default gnuplot will close a display window as soon as it finishes drawing.
I don't run an ntp daemon.Instead, I just sync my clock once a day using ntpdate.
The ntpdate log file looks like this:
28 Jul 04:02:41 ntpdate[4781]: step time server 192.43.244.18 offset 13.828862 sec 29 Jul 04:02:45 ntpdate[19059]: step time server 192.43.244.18 offset 13.838561 sec 30 Jul 04:03:36 ntpdate[17510]: step time server 192.43.244.18 offset 13.844762 sec
I save the output from ntpdate to a log file. I can plot the daily clock drift using this gnuplot script:
set data style errorlines set title "Daily clock offset\nnegative means clock runs fast" set xlabel "Date" set xdata time set timefmt "%d %b %H:%M:%S" set format x "%d/%m" set ylabel "Required offset (negative minutes fast)" set yrange [ -1.0 : 30.0] set grid plot "ntpdate.log" using 1:10
For using with `cdck`
#!/usr/bin/env gnuplot set data style errorlines set terminal x11 set grid set xlabel 'Sectors (2Kb/sec)' set ylabel 'Reading time (usec)' set logscale y plot 'cdck-plot.dat' with lines pause -1
old style, depricated:
set terminal png #gif small size 640,480 set title "Daily clock offset\nnegative means clock runs fast" set data style fsteps set xlabel "Date" set timefmt "%d/%m/%y\t%H%M" set yrange [ -4.6 : -4.8] set xdata time set xrange [ "25/06/00":"29/08/00" ] set ylabel "Required offset (negative minutes fast)" set format x "%d/%m" #\n%H:%M" set grid set key left plot "data.dat" using 1:10 reset