我正在尝试从内联文件中绘制“x; y1; y2”数据:
set xdata time
set timefmt "%Y-%m-%dT%H:%M:%S"
set format x "%H:%M:%S"
set datafile separator ";"
set yrange [0:]
plot '-' index 0 using 1:2 with linespoints t 'before', '-' index 0 using 1:3 with linespoints t 'after'
2015-11-05T00:42:32;0.690000;0.690000
2015-11-05T00:43:34;0.690000;0.690000
2015-11-05T00:44:35;0.690000;0.690000
2015-11-05T00:45:36;0.690000;0.690000
2015-11-05T00:46:37;0.690000;0.690000
2015-11-05T00:47:38;0.690000;0.690000
2015-11-05T00:48:38;0.690000;0.690000
2015-11-05T00:49:40;0.690000;0.690000
e
gnuplot - 然而 - 抱怨第二部分没有数据。在重复数据时,如
set xdata time
set timefmt "%Y-%m-%dT%H:%M:%S"
set format x "%H:%M:%S"
set datafile separator ";"
set yrange [0:]
plot '-' index 0 using 1:2 with linespoints t 'before', '-' index 0 using 1:3 with linespoints t 'after'
2015-11-05T00:42:32;0.690000;0.690000
2015-11-05T00:43:34;0.690000;0.690000
2015-11-05T00:44:35;0.690000;0.690000
2015-11-05T00:45:36;0.690000;0.690000
2015-11-05T00:46:37;0.690000;0.690000
2015-11-05T00:47:38;0.690000;0.690000
2015-11-05T00:48:38;0.690000;0.690000
2015-11-05T00:49:40;0.690000;0.690000
e
2015-11-05T00:42:32;0.690000;0.690000
2015-11-05T00:43:34;0.690000;0.690000
2015-11-05T00:44:35;0.690000;0.690000
2015-11-05T00:45:36;0.690000;0.690000
2015-11-05T00:46:37;0.690000;0.690000
2015-11-05T00:47:38;0.690000;0.690000
2015-11-05T00:48:38;0.690000;0.690000
2015-11-05T00:49:40;0.690000;0.690000
e
我希望index 0
选择了正确的数据集。
我还试图省略第二个“文件”名称以再次使用最后一个文件。
有没有更好的方法再次使用相同的内联数据而不重复?
答案 0 :(得分:4)
由于5.0版gnuplot有一个新的“命名数据块”结构(如heredoc),它允许您保存内联数据一次并按需使用它:
$data <<EOD
2015-11-05T00:42:32;0.690000;0.690000
2015-11-05T00:43:34;0.690000;0.690000
2015-11-05T00:44:35;0.690000;0.690000
2015-11-05T00:45:36;0.690000;0.690000
2015-11-05T00:46:37;0.690000;0.690000
2015-11-05T00:47:38;0.690000;0.690000
2015-11-05T00:48:38;0.690000;0.690000
2015-11-05T00:49:40;0.690000;0.690000
EOD
set xdata time
set timefmt "%Y-%m-%dT%H:%M:%S"
set format x "%H:%M:%S"
set datafile separator ";"
set yrange [0:]
set style data linespoints
plot $data using 1:2 t 'before', '' using 1:3 t 'after'