所有数据集的gnuplot自动图例生成

时间:2016-07-12 18:34:54

标签: gnuplot legend

我想知道如何使用下面的“option-1”绘图命令自动生成图例。我得到三条曲线,但只有一个图例名称,即只显示“Y0”。

使用“option-2”我可以获得所有图例名称,但我不喜欢大数据集的这种方法。

情节文件的内容:

set key autotitle columnhead

#option-1
plot "dataset" skip 1 index 0:2:1 using 1:2:(1+column(-2)) title\
     columnhead with linespoints  linecolor variable

#option-2
plot "dataset" skip 1 index 0 using 1:2 title columnhead with linespoints,\
     "" skip 1 index 1 using 1:2 title columnhead with linespoints,\
     "" skip 1 index 2 using 1:2 title columnhead with linespoints

“数据集”文件的内容:

文本文件

#index_0
X0      Y0
0       1
1       2
2       3
3       4


#index_1
X1       Y1
0        2
1        3
2        4
3        5


#index_2
X2        Y2
0         3
1         4
2         5
3         6

1 个答案:

答案 0 :(得分:1)

不确定如何解决您的选项-1,但您可以使用for循环自动执行大型数据集的选项-2:

N=2 # last index
plot for [i=0:N] "dataset" skip 1 index i using 1:2 title columnhead with linespoints