在 gnuplot 中对多个单独的绘图使用内联数据

Use inline data for mutiple individual plots in gnuplot

我正在尝试绘制来自内联文件的 "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 能够完成工作,index 0 选择了正确的数据集。 我还尝试省略第二个 "file"name 以再次使用最后一个文件。

有没有更好的方法可以再次使用相同的内联数据而不重复?

从 5.0 版开始,gnuplot 有了一个新的 "named data block" 结构(如 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'