Reputation: 4325
It seems my gnuplot knowledge is getting rusty; at least I don't see what's wrong:
I have a data file that looks like this (the actual file has more than 50000 lines, fields are separated by TABs):
#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
The gnuplot session looks like this:
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>
Initially I had used "%F" instead of "%Y-%m-%d", but even now it won't work, and I don't see why. The example session was made with gnuplut 5.2 patchlevel 2, while originally the problem was found in 5.2 patchlevel 8.
The data format should be obvious: YYYY-MM-DD HH:MM:SS
Upvotes: 1
Views: 463
Reputation: 25714
Placeholders %F
(date) and %T
(time) are not valid for set timefmt
.
So when using these commands instead, things should work smoothly:
set xdata time
set timefmt "%Y-%m-%d %H:%M:%S"
plot "attrlog.short" u 1:6 w lp
Details can be found in help time_specifiers
:
%F
and%T
are only for output, not for input as you are trying.
Output: set format x '%F %T'
will work, but
Input: set timefmt '%F %T'
will not work according to documentation.
Change it to set timefmt '%Y-%m-%d %H:%M:%S'
.
Be aware:
If you want to plot the column with 95
in your data example
and if your separator is whitespace (default), you have to specify column 7.
and if you explicitly have TAB as separator (that's what you specify later) and the space within your date/time is "normal" space then column 6 is fine.
Upvotes: 1