【发布时间】:2022-01-28 08:23:06
【问题描述】:
看来我的 gnuplot 知识越来越生疏了;至少我看不出有什么问题:
我有一个看起来像这样的数据文件(实际文件有超过 50000 行,字段由 TAB 分隔):
#date-and-time(0) 1(1) 5(2) 9(3) 12(4) 13(5) 170(6) 174(7) 179(8) 180(9) 181(10) 182(11) 184(12) 194(13) 195(14) 197(15) 198(16) 199(17) 201(18) 202(19) 225(20) 226(21) 227(22) 228(23) 232(24) 233(25) 234(26) 241(27) 242(28) 245(29)
2022-01-24 05:36:22 130 100 100 100 95 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100
2022-01-24 06:06:22 130 100 100 100 95 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100
2022-01-24 06:36:22 130 100 100 100 95 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100
2022-01-24 07:06:22 130 100 100 100 95 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100
gnuplot 会话如下所示:
Terminal type is now 'qt'
gnuplot> plot "attrlog.short" using 1:6 with linesp
Warning: empty x range [2022:2022], adjusting to [2001.78:2042.22]
Warning: empty y range [100:100], adjusting to [99:101]
gnuplot> set dataf sep tab
gnuplot> set form x "%F %T"
gnuplot> set timefmt "%F %T"
gnuplot> set xdata time
gnuplot> repl
2022-01-24 05:36:22 130 100 100 100 95 100 100 100 100 100 100 100 100 100 10...
attrlog.short:2: warning: Bad time format in string
2022-01-24 05:36:22 130 100 100 100 95 100 100 100 100 100 100 100 100 100 10...
attrlog.short:2: warning: Bad time format in string
2022-01-24 06:06:22 130 100 100 100 95 100 100 100 100 100 100 100 100 100 10...
attrlog.short:3: warning: Bad time format in string
2022-01-24 06:06:22 130 100 100 100 95 100 100 100 100 100 100 100 100 100 10...
attrlog.short:3: warning: Bad time format in string
2022-01-24 06:36:22 130 100 100 100 95 100 100 100 100 100 100 100 100 100 10...
attrlog.short:4: warning: Bad time format in string
2022-01-24 06:36:22 130 100 100 100 95 100 100 100 100 100 100 100 100 100 10...
attrlog.short:4: warning: Bad time format in string
2022-01-24 07:06:22 130 100 100 100 95 100 100 100 100 100 100 100 100 100 10...
attrlog.short:5: warning: Bad time format in string
2022-01-24 07:06:22 130 100 100 100 95 100 100 100 100 100 100 100 100 100 10...
attrlog.short:5: warning: Bad time format in string
Warning: empty x range [0:0], adjusting to [-1:1]
Warning: empty y range [95:95], adjusting to [94.05:95.95]
gnuplot> set form x "%Y-%m-%d %T"
gnuplot> set timefmt "%Y-%m-%d %T"
gnuplot> repl
2022-01-24 05:36:22 130 100 100 100 95 100 100 100 100 100 100 100 100 100 10...
attrlog.short:2: warning: Bad time format in string
2022-01-24 06:06:22 130 100 100 100 95 100 100 100 100 100 100 100 100 100 10...
attrlog.short:3: warning: Bad time format in string
2022-01-24 06:36:22 130 100 100 100 95 100 100 100 100 100 100 100 100 100 10...
attrlog.short:4: warning: Bad time format in string
2022-01-24 07:06:22 130 100 100 100 95 100 100 100 100 100 100 100 100 100 10...
attrlog.short:5: warning: Bad time format in string
Warning: empty x range [1.64298e+09:1.64298e+09], adjusting to [1.62655e+09:1.65941e+09]
Warning: empty y range [95:95], adjusting to [94.05:95.95]
gnuplot>
最初我使用“%F”而不是“%Y-%m-%d”,但即使现在它也不起作用,我不明白为什么。 示例会话是使用 gnuplut 5.2 patchlevel 2 创建的,而最初问题是在 5.2 patchlevel 8 中发现的。
数据格式应该很明显:YYYY-MM-DD HH:MM:SS
【问题讨论】:
-
检查
help time_specifiers:%F和%T仅用于输出,而不是您尝试的输入。输出:set format x '%F %T'将起作用,但输入:set timefmt '%F %T'根据文档将不起作用。 -
set timefmt "%Y-%m-%d %T"将不起作用。这就是为什么你会得到"Bad time format in string"。将其更改为set timefmt "%Y-%m-%d %H:%M:%S"。 -
愚蠢的我:你是对的:我读过
%F,但错过了%T。