我有以下数据系列:
201708201600 1.175588 1.175631 1.175553 1.175591
201708202000 1.175564 1.175604 1.175520 1.175561
201708210000 1.174651 1.174711 1.174582 1.174644
201708210400 1.174855 1.174935 1.174785 1.174862
201708210800 1.179250 1.179381 1.179146 1.179268
201708211200 1.181497 1.181555 1.181437 1.181495
201708211600 1.181187 1.181228 1.181142 1.181185
201708212000 1.181156 1.181195 1.181113 1.181151
201708220000 1.179908 1.179969 1.179837 1.179902
201708220400 1.176303 1.176397 1.176190 1.176293
201708220800 1.176182 1.176286 1.176073 1.176177
201708221200 1.175669 1.175722 1.175607 1.175667
201708221600 1.176249 1.176292 1.176201 1.176249
201708222000 1.175689 1.175735 1.175640 1.175687
201708230000 1.175872 1.175956 1.175803 1.175881
201708230400 1.178496 1.178590 1.178409 1.178501
201708230800 1.180339 1.180446 1.180235 1.180339
201708231200 1.181056 1.181128 1.180989 1.181063
201708231600 1.181169 1.181212 1.181126 1.181168
201708232000 1.180509 1.180546 1.180466 1.180502
201708240000 1.179841 1.179903 1.179779 1.179836
201708240400 1.179210 1.179283 1.179138 1.179215
201708240800 1.180083 1.180180 1.179983 1.180079
201708241200 1.180609 1.180661 1.180560 1.180609
201708241600 1.179991 1.180023 1.179961 1.179991
201708242000 1.179487 1.179522 1.179448 1.179485
201708250000 1.179193 1.179242 1.179133 1.179185
201708250400 1.180497 1.180586 1.180420 1.180508
201708250800 1.183690 1.183868 1.183538 1.183712
201708251200 1.189021 1.189156 1.188896 1.189041
201708251600 1.192202 1.192281 1.192131 1.192194
第一列代表日期/时间YYYYMMDDhhmm
。
这意味着在此示例中,每4小时就有一次数据。
我需要获得:
我尝试过:
set timefmt "%Y%m%d%H%M"
set format x "%b %d"
set xdata time
有效地将日期/时间设置为月份名称和日期编号。
如何强制每天发生大变动,而其余数据为小变动?
因此,在这种情况下,我希望对以下内容进行大笔交易:
- (2 minor ticks for 16:00 and 20:00)
Aug 21 (6 minor ticks for 00:00 to 20:00)
Aug 22 (6 minor ticks for 00:00 to 20:00)
Aug 23 (6 minor ticks for 00:00 to 20:00)
Aug 24 (6 minor ticks for 00:00 to 20:00)
Aug 25 (6 minor ticks for 00:00 to 20:00)
Aug 26 (5 minor ticks for 00:00 to 17:00)
因此,我们的想法是,我们每4小时(根据数据)标记一个勾号,但文本仅在新的一天开始时出现,这使得图表易于阅读。
答案 0 :(得分:1)
首先是一个简单的解决方案,它可能会也可能不适合您的一般情况:
# Option 1: tic pattern is independent of data in file
# Set one major tic per day with minor tics every 4 hours
seconds_per_day = 60.*60.*24.
set xtics seconds_per_day
set mxtics 6
如果每个数据条目确实需要一个tic,而没有其他功能,那么它将变得更加复杂。首先请注意,此命令将为文件中的每个条目放置一个tic标记,但是它们都没有标签:
plot 'time.dat' using 1:2:xtic("") with lp
现在让我们通过定义一个标签函数来扩展它,该函数从N列读取一个字符串并打印一个空标签,除非最后四个字符为0000(即午夜)。在午夜,它将时间值重新格式化为您首选的“%b%d”:
label(N) = (strcol(N)[9:12] eq "0000") \
? strftime("%b %d",timecolumn(N,"%Y%m%d%H%M")) \
: ""
完整的绘图命令如下所示
plot 'time.dat' using 1:2:xtic(label(1)) with lp