I have to plot data depending on time. The time is expressed in seconds
and goes from 0.00 to 86399.99 (one day actually). I want to plot my
data according a particular range of time, and I want to format my
'xtics' like %H:%M:%S.
Example of data :
my X my Y
| |
1 30791.648 316.547 -185.578 18.500 2244.000 8.000 0 0 0
1 30795.344 316.703 -185.656 20.250 2262.000 7.688 0 0 0
1 30799.047 316.859 -185.734 20.250 2262.000 7.078 0 0 0
1 30802.734 317.016 -185.812 23.000 2385.000 6.594 0 0 0
1 30806.438 317.172 -185.906 24.000 2502.000 6.125 0 0 0
1 30810.125 317.312 -185.984 25.750 2695.000 5.672 1 2 3
1 30813.828 317.453 -186.078 28.000 2813.000 5.250 1 2 3
1 30817.523 317.609 -186.188 29.500 2836.000 4.844 1 2 3
1 30817.523 317.609 -186.188 29.500 2836.000 4.844 1 5 3
1 30821.219 317.766 -186.266 31.250 2795.000 4.453 0 0 0
1 30824.914 317.906 -186.359 32.500 2443.000 4.078 0 0 0
1 30828.609 318.031 -186.453 33.750 1986.000 3.734 0 0 0
1 30832.305 318.172 -186.594 35.000 1893.000 3.406 0 0 0
1 30836.234 318.234 -186.781 35.750 1734.000 3.516 0 0 0
Example of gnuplot file :
set xrange [30800.000:30837.000]
set xdata time
set timefmt '%s'
set format x "%H:%M:%S"
set tics out nomirror scale 0.5
set format y '%5.1f'
set autoscale y
plot 'mydata' using 2:($7>0 ? $7 :0/0) with lines 1
As I didn't succeed in re-using the %s time-format, I changed the
behaviour of '%s' in time.c and put the line "s = read_int(s, 10,
tm->tm_sec);" instead of current source. But I'll be forced to repeat
this "blot" each time I will update gnuplot.
Maybe is there a nicer method to plot my data that could avoid to modify
data or source code ?
Vincent
> As I didn't succeed in re-using the %s time-format,
And _how_ didn't you succeed? I.e.: what went wrong? And what, anyway,
is the difference between "re-using" and just "using" a feature?
Finally, I found an other method by introducing an offset of time. But
it led me to prefer the printf function rather than print function of
awk, maybe because of the scientific notation.
Here are some tries (I kept the xrange set to [30800.000:30837.000]) :
1> plot "< awk '{print $2,$7}' mydata" using 1:($2>0 ? $2 :0/0) with lines 1
I got the error message "all points y value undefined!" (Same error with
printf)
2> plot "< awk -v offset=946684800 '{print $2+offset,$7}' mydata" using
1:($2>0 ? $2 :0/0) with lines 1
Same error
3> plot "< awk -v offset=946684800 '{printf(\"%f %f\\n\",
$2+offset,$7)}' mydata" using 1:($2>0 ? $2 :0/0) with lines 1
It's OK
> And what, anyway, is the difference between "re-using" and just
> "using" a feature?
Sorry, I expressed myself badly ...
Vincent
Someone suggested me a neat way to plot my data :
[previous commands keep unchanged]
"plot 'mydata' using ($2):7 with lines 1"
instead of
"plot 'mydata' using 2:7 with lines 1"
It seems to work, but I can't explain myself why '($2)' and not
'2' ...