gnuplot:多图在每个图中使用多条线和在线数据

gnuplot: multiplots using multiple lines in each plot and in-line data

我正在尝试从 torch 调用 gnuplot 以绘制几件事情。我正在尝试使用多图(​​如 matlab 中的子图),同时在同一图中绘制不同的曲线。此外,我在线定义数据,即避免将数据写入外部文件(绘图“-”)。

我已经尝试以多种方式用“-”绘制多条曲线,使用多图上一个和下一个,使用重绘...但是任何组合都会以一种或另一种方式弄乱布局。有谁知道如何做到这一点或可以给出一些提示?

谢谢!

更新: 添加了一个小例子。蓝线和红线应绘制在同一图中(上图),而绿线应单独绘制在下图。

示例:

gnuplot.figure(1)
gnuplot.raw('set terminal x11 0 position 1200,20 persist')
gnuplot.raw('set multiplot layout 2,1')

gnuplot.raw([[plot '-' lt rgb 'blue'
            0 0
            100 30
            e]])

gnuplot.raw([[plot '-' lt rgb 'red'
            0 30
            100 60
            e]])

gnuplot.raw([[plot '-' lt rgb 'green'
            0 60
            100 90
            e]])

gnuplot.raw('unset multiplot')

我不熟悉 torch,但我认为你的问题在于尝试做三个单独的情节陈述。在 gnuplot 中,要在同一个图中绘制多条曲线(顶部图中有两条),您可以在同一个命令中指定它们,并用逗号分隔。 Feeding inline data,这意味着你需要提供一组数据,以e结尾,提供另一组,然后以e结尾。

此外,您可以使用 lc(线条颜色)代替 lt 来设置颜色。

在直接的 gnuplot 中,您将这样做:

set terminal x11 0 position 1200,20 persist
set multiplot layout 2,1
plot '-' lc rgb 'blue', '-' lc rgb 'red'
0 0
100 30
e
0 30
100 60
e
plot '-' lc rgb 'green'
0 60
100 90
e
unset multiplot

如果你想要线条,只需将 with lines 添加到所有三个绘图规范中,如

plot '-' lc rgb 'blue' with lines, '-' lc rgb 'red' with lines
plot '-' lc rgb 'green' with lines

或使用set style data lines更改默认数据样式。