As of 4.6 gnuplot manage seconds with doubles allowing to go beyond seconds.
It possible to print time up to µs with
gnuplot>print strftime("%H:%M:%.3S %d-%b-%Y",time(0.0)) 12:04:32.875415 22-Sep-2014
however the timemft does not support telling there is µs.
Not sure this limitation on timemft is the source of the trouble I have, however it can.
Here the issue I have.
I have series of data that are expresses by time and data
time is HH::MM::SS.ssssss
data is a number
Let's consider this data series as an example
12:31:01.354684 5 12:31:01.489654 20 12:31:01.579654 30 12:31:01.687654 20 12:31:01.707654 5
and this gnuplot commands
set xdata time set timefmt "%H:%M:%S" set xtics format "%H:%M:%.6S" data="./data" set table plot data using 1:2
that will gives this output below
# Curve 0 of 1, 5 points # Curve title: "data using 1:2" # x y type "12:31:01.354000" 5 i "12:31:01.489000" 20 i "12:31:01.579000" 30 i "12:31:01.687000" 20 i "12:31:01.707000" 5 i
1st my precision is truncated to ms, this is as per documentation, however print strftime("%H:%M:%.3S %d-%b-%Y",time(0.0)) gives up to µs, so I think it would be better to support µs every where.
Now in my case I want my T0 to be 00:00:00.000000.
So I want to substract the time found on my 1st raw when ploting.
The trick I use (I do not want to sues systeme command as I need my gnplot command files to work on any OS) is
plot data every ::0:0:0:1 using (t0=$1):2 with lines
that gives the output
# Curve 0 of 1, 1 points # Curve title: "data every ::0:0:0:1 using (t0=$1):2" # x y type "00:00:12.000000" 5 i
Strange considering my data serie
I would think that $1 is the first column/first row data
but it is not, it is converted to a float not reprsenting a time data so I cannot substract it from a time.
I tried also
gnuplot> plot data every ::0:0:0:1 using (t0=strftime("%H:%M:%.6S",$1)):2 with lines
This gives the same result
# Curve 0 of 1, 1 points # Curve title: "data every ::0:0:0:1 using (t0=strftime("%H:%M:%.6S",$1)):2" # x y type "00:00:12.000000" 5 i
If I want to plot using my t0 variable I got this
plot data using ($1-t0):2 Warning: empty x range [0:0], adjusting to [-1:1] # Curve 0 of 1, 5 points # Curve title: "data using ($1-t0):2" # x y type "00:00:00.000000" 5 i "00:00:00.000000" 20 i "00:00:00.000000" 30 i "00:00:00.000000" 20 i "00:00:00.000000" 5 i
All my time are equal to 0
Ticket moved from /p/gnuplot/bugs/1484/
Accessing an x column with time data via $1 (or column(1)) seems to not work (bug?), but you can use this:
plot data ev ::::0 using (t0=strptime("%H:%M:%S",stringcolumn(1))):2; print t0
In gp5 (and windows gp464 also, btw.) this even gives you dates with microsecond resolution.
P.S. You used strftime(), that takes number of seconds and returns a date string.
Last edit: Karl Ratzsch 2014-10-02
P.S. As of gp5, the function timecolumn() supports supplying a format string, so you won´t even need "set xdata time"/"set timefmt" any more.
plot $data using (t0=timecolumn(1,"%H:%M:%S")):2; print t0