Gnuplot为时间序列图绘制了不正确的时间 [英] Gnuplot plots incorrect time for time series plot
问题描述
我正在打印具有以下格式的时间序列
I'm printing a time series that has the following format
> 1400536853 0.011955
> 1400537188 0.013695
> 1400537530 0.010797
> ....
> 1400621709 0.010688
> 1400622023 0.007209
> 1400622338 0.006685
> 1400622653 0.005539
第一列是unix纪元格式的时间戳,第二列是要绘制的变量. 请注意,第一行的时间戳对应于"2014年5月20日星期二00:00:53 CEST",最后一行对应于"2014年5月20日星期二23:50:53 CEST 2014".我使用以下命令对此进行了验证:
The first column is a timestamp in unix epoch format and the second is a variable to plot. Notice that the timestamp pf the first line corresponds to "Tue May 20 00:00:53 CEST 2014" and the last line to "Tue May 20 23:50:53 CEST 2014". I veridied this with the following command:
date -d @<timestamp>
我正在使用以下脚本绘制时间序列
I'm using the following script to plot the time series
set xdata time
set timefmt '%s'
set format x '%H'
plot 'series.txt' using 1:2 with lines notitle
但是我得到了一个小时数在22、00、02范围内的图形....22如下图所示:
But I'm getting a plot with hours in the range 22, 00, 02. ...22 as shown in the next figure:
对于解决此问题的任何建议,我将不胜感激.这可能与未正确设置时区有关吗?预先致谢
I will appreciate any suggestion on how to fix this. May this has to do with not setting properly the timezone? Many thanks in advance
推荐答案
Gnuplot无法更改时区,并且对所有时间数据使用UTC.这是您2小时班次的来源:
Gnuplot cannot change the time zone and uses UTC for all time data. This is where your 2h shift comes from:
$ date -u -d @1400536853
Mo 19. Mai 22:00:53 UTC 2014
在特定情况下,您只需在using
语句中添加两个小时即可:
In your specific case, you can just add the two hours in the using
statement:
set xdata time
set timefmt '%s'
set format x '%H'
plot 'series.txt' using ($1 + 2*60*60):2 with lines notitle
请注意,这是明确假设的,您只能在相同时区的计算机上运行脚本.我认为没有通用的方法可以在gnuplot中的时区之间进行转换,因为它不支持它们.
Beware, that this explicitely assumes, that you run the script only on computers in the same time zone. I think there is no generic way to convert between time zones within gnuplot, since it doesn't support them.
这篇关于Gnuplot为时间序列图绘制了不正确的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!