Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gnuplot: how to plot date / time chart

Tags:

gnuplot

I would like to plot this kind of data:

  • X axis: dates
  • Y axis: time lenght

The data would looks like that:

22/02 51:10
25/02 63:10
01/03 50:55
23/03 52:10

I already done that for the X axis:

set xdata time
set timefmt "%d/%m"

But I don't know how to manage Y axis.

like image 506
Jérôme Avatar asked Feb 23 '11 09:02

Jérôme


2 Answers

As Tom said, you can only use one timefmt. However, if it is possible to split your data to more columns like this:

22/02 51 10
25/02 63 10
01/03 50 55
23/03 52 10

you can then plot the time length by direct calculation, like this:

plot 'file' u 1:($2 + $3/60)

to plot minutes, or like this:

plot 'file' u 1:($2/60 + $3/3600)

to plot hours.

like image 132
Eelvex Avatar answered Oct 15 '22 05:10

Eelvex


From ?xdata

There is currently only one timefmt, which implies that all the time/date columns must conform to this format.

So you need to alter your data somewhat to conform to one setting.

something like

00:00:22/02 51:10:22/02
00:00:25/02 63:10:22/02
00:00:01/03 50:55:22/02
00:00:23/03 52:10:22/02

Note that you can use command line tools to do this within gnuplot, see here

Once the file is edited you can read it like so

set xdata time
set ydata time
set timefmt "%M:%S:%d/%m"
set format x "%d/%m"
set format y "%M:%S"
plot "date_time.dat" u 1:2 w l
like image 26
Tom Avatar answered Oct 15 '22 04:10

Tom