At present I'm using gnuplot to plot data against a time line. However the precision of the time line is in milliseconds but gnuplot only seems to be able to handle seconds.
I've looked at a couple of alternatives, but really I just need something like gnuplot that can cope with fractions of a second.
The programming language used for the main script is Python and whilst I've looked at matplotlib, it seems to be a lot more 'heavy duty' than gnuplot. As I won't always be the one updating the graphing side of things, I want to keep it as easy as possible.
Any suggestions?
Update
I'm using this with gnuplot:
set xdata time
set timefmt "%Y-%m-%d-%H:%M:%S"
However there is no %f to get milliseconds. For example, this works:
2011-01开发者_如何学Python-01-09:00:01
but I need:
2011-01-01-09:00:01.123456
According to the gnuplot 4.6 manual it states, under "Time/date specifiers" (page 114 of the gnuplot 4.6 PDF):
%S - second, integer 0–60 on output, (double) on input
What this means is that when reading timestamps such as 2013-09-16 09:56:59.412
the fractional portion will be included as part of the %S
specifier. Such a timestamp will be handled correctly with:
set timefmt "%Y-%m-%d %H:%M:%S"
set datafile separator ","
plot "timed_results.data" using 1:2 title 'Results' with lines
and fed with data like:
2013-09-16 09:56:53.405,10.947
2013-09-16 09:56:54.392,10.827
2013-09-16 09:56:55.400,10.589
2013-09-16 09:56:56.394,9.913
2013-09-16 09:56:58.050,11.04
You can set the ticks format with
set format x '%.6f'
or (maybe, I have not tried it, as I now prefer to use Matplotlib and do not have gnuplot installed on my machines):
set timefmt "%Y-%m-%d-%H:%M:%.6S"
(note the number of digits specified along with the %S
format string).
More details can be found in the excellent not so Frequently Asked Questions.
I'm using gnuplot for the same purposes, my input looks like:
35010.59199,100,101
35010.76560,100,110
35011.05703,100,200
35011.08119,100,110
35011.08154,100,200
35011.08158,100,200
35011.08169,100,200
35011.10814,100,200
35011.16955,100,110
35011.16985,100,200
35011.17059,100,200
The first column is seconds since midnight and after the comma a nanosecond part. You can save this in a csv file and in gnuplut do:
set datafile separator ','
plot "test.csv" using 1:3 with lines
I originally misunderstood your problem. I think the finer resolution to the time format is a big problem with gnuplot and one that to my knowledge is not implemented.
One possible work-around would be to use awk to convert your date into the number of seconds with something like
plot "<awk 'your_awk_one_liner' file1.dat" with lines
and then just do a regular double by double plot and forget that it was every time at all (a bit like Martin's solution). I'm afraid I am not very good with awk and so I cannot help with this bit - these pages might help though - http://www.gnu.org/manual/gawk/html_node/Time-Functions.html and http://www.computing.net/answers/unix/script-to-convert-datetime-to-seco/3795.html. The use of awk with gnuplot is described here: http://t16web.lanl.gov/Kawano/gnuplot/datafile3-e.html.
You could then plot a second axis (and not the data) with the correct times - something like the method used here: Is there a way to plot change of day on an hourly timescale on the x axis?
I'm afraid I don't have time to try and write a complete solution - but something reasonable should be possible.
Good luck - keep us updated if you get something working - I would be interested.
精彩评论