Gnuplot: how to plot date / time chart

萝らか妹 提交于 2019-12-23 08:36:15

问题


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.


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/5089284/gnuplot-how-to-plot-date-time-chart

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!