Mix date and time by gnuplot xaxis

I would like to plot the hours of the day on the x axis, but print the date when the day flips from one day to another. So the x axis might look like this:

11/02 04:00 08:00 12:00 16:00 20:00 11/03 04:00 08:00 ...

Is there any reasonable way to do this in gnuplot?

FWIW, my file currently looks something like this:

set xdata time
set timefmt "%Y-%m-%d|%H:%M:%S"
plot '-' using 1:2 with lines linewidth 1 linecolor rgb "#FF0000"
2013-11-02|00:00:48 123.0
2013-11-02|00:00:55 124.0
2013-11-02|00:01:06 121.0
2013-11-02:00:01:17 123.0
...
2013-11-04|23:59:41 241.0
2013-11-04|23:59:52 241.0
+2
source share
1 answer

It's hard, made me think a little. Here's how you can do it:

You need to set the x axis format to %H:%M, and then replace with 00:00dates similar to those made in this answer .

, . stats (, , 4.6.0), , strptime :

fmt = "%Y-%m-%d|%H:%M:%S"
stats 'file.txt' using (strptime(fmt, stringcolumn(1))) nooutput
t = int(STATS_min)
t_start = t - tm_hour(t)*60*60 - tm_min(t)*60 - tm_sec(t)
num_days = 2 + (int(STATS_max) - t)/(24*60*60)

set xdata time
set timefmt fmt
set xtics 4*60*60
set for [i=1:num_days] xtics add (strftime('%m/%d', t_start+(i-1)*24*60*60) t_start+(i-1)*24*60*60)
set format x '%H:%M'
plot 'file.txt' using 1:2 with lines

num_days 2, x- .

( 4.6.4):

enter image description here

+3

All Articles