在中午/中午显示基于xtics的时间

时间:2014-11-11 21:57:32

标签: gnuplot

我有一些csv数据我试图在gnuplot中绘图。

示例:

1,2014-11-07T17:01
2,2014-11-08T11:53
3,2014-11-08T18:50
4,2014-11-09T09:42
5,2014-11-10T11:40
6,2014-11-11T12:34

我正在使用

set xtics format "%a"

显示一周中的短日名称(周一,周二,周三),每天午夜显示一次。

我怎样才能让gnuplot在中午/中午/中午12点而不是午夜时显示xtics?

1 个答案:

答案 0 :(得分:1)

这与问题mixing date and time on gnuplot xaxis有点类似。它基本上是根据数据文件中的第一个日期提取第一个正午的时间戳。然后,您可以使用此时间戳作为设置xtics的开始。

使用statsstrptime以及其他一些时间函数完成第一个中午的提取:

reset
fmt = "%Y-%m-%dT%H:%M"
set datafile separator ','
stats 'test.txt' using (strptime(fmt, strcol(2))) every ::::0 nooutput
t = int(STATS_min)
t_start_midnight = t - tm_hour(t)*60*60 - tm_min(t)*60 - tm_sec(t)
t_start_noon = t_start_midnight - 12*60*60

然后您可以使用

绘制数据
set xdata time
set timefmt fmt
set xtics t_start_noon, 24*60*60

set format x '%a'
plot 'test.txt' using 2:1 with lp pt 7 ps 2 notitle

注意,stats在时间模式下无效,必须在set xdata time之前调用。

xtics at noon

相关问题