Millisecond Time Resolution X/Y Scatter Plotting With Gnuplot
September 16, 2013
Posted by on
So you have timestamps with a resolution of milliseconds and you want to plot them on a X/Y scatter graph using Gnuplot.
This is possible because the %S specifier in timefmt accepts a double (i.e. a floating point value) so that the fractional portion of the time will be interpreted as a fraction of seconds.
You can print fractional seconds on the X-axis using the set format x “%H:%M:%.3S” command.
Here is a Gnuplot plot file to demonstrate this:
set terminal png size 400,320 font 'Verdana,8'
set output 'test.png'
set datafile separator ","
set xdata time
set timefmt "%Y-%m-%d %H:%M:%S"
set format x "%H:%M:%.3S"
set title 'Speed over Time'
set xlabel "Timestamp"
set ylabel "km/h"
set xrange ["2013-09-16 10:59:05.000":"2013-09-16 10:59:06.000"]
set yrange [0:12]
set xtics out rotate by -80
set key below
set pointsize 1.0
plot '-' using 1:2 title 'My Car' with points pointtype 2
If you run this you should get the following image created:
Gnuplot 4.6 Millisecond Resolution Scatter Plot
The documentation for Gnuplot is available at the Gnuplot documentation home page. Note that you might need a recent version of Gnuplot to achieve millisecond-resolution plotting as it appears this was introduced into version 4.6.