【发布时间】:2015-06-23 19:45:06
【问题描述】:
我有一个大型 (80MB+) 输入文件,其中包含这样的样本(第一列中的时间戳是 UNIX 纪元,单位为毫秒):
1433908383.289 25219.334734712 25219.946173616 9.512001270e-06 1.003999932e-05 9.512001270e-06 1.003999932e-05 0.000000000e+00 0.000000000e+00
1433908383.336 25219.364742792 25219.985225320 9.528001101e-06 1.003999932e-05 9.528001101e-06 1.003999932e-05 0.000000000e+00 0.000000000e+00
1433908383.362 25219.399744192 25220.016488160 9.512001270e-06 1.003199941e-05 9.512001270e-06 1.003199941e-05 0.000000000e+00 0.000000000e+00
1433908383.386 25219.429734824 25220.039910600 9.504001355e-06 1.003999932e-05 9.504001355e-06 1.003999932e-05 0.000000000e+00 0.000000000e+00
当使用以下脚本绘制时:
set terminal pngcairo enhanced font "arial,10" size 1024, 768;
set key below;
set grid;
set xdata time;
set timefmt "%H:%M:%S";
set format x "%H:%M:%S";
set datafile separator "\t";
set xlabel "Time (UTC)";
set ylabel "seconds";
set datafile nofpe_trap;
plot "data.tsv" using ($1-946684800):6 with points linecolor rgbcolor "#EE0000" axes x1y1 title "plot 1";
生成以下图表:
但是当我在plot 命令之前添加以下内容时:
set xrange ["10:00:00","11:00:00"]
我没有得到任何输出并出现以下错误:
gnuplot> plot "data.tsv" using ($1-946684800):6 with points linecolor rgbcolor "#EE0000" axes x1y1 title "plot 1";
^
line 0: all points y value undefined!
我已经匹配了timefmt,并且在这个范围内显然有数据。那么是什么给出的呢?
注意:这是 gnuplot 4.4,下图的轴标签错误,因为我最初在纪元偏移中遗漏了 8。
【问题讨论】:
-
问题是,“10:00:00”不是唯一定义的。如果没有给出日期、月份和年份,gnuplot 4.4 将使用 2000 年 1 月的第一个,这不是您的数据所在的位置。
-
但我不是必须以
timefmt格式提供xrange吗?我的timefmt没有日期组件。我该如何解决这个问题? -
设置 xrange 是您的
set timefmt的唯一应用,因为您在读取数据时明确规避了 timefmt 设置。取而代之的是,您还可以以秒为单位给出 xrange(自 2000 年 1 月 1 日起),就像您对 x 值所做的那样。 -
@Christoph:啊啊啊
$1在做什么,绕过timefmt?我想我明白了。 -
是的,我认为这很清楚。 Ups :) 我编辑了另一个答案以使其更清楚。
标签: gnuplot