gnuplot - 删除线条标题

38

我尝试搜索,但是在这个特定条件下我无法找到解决方案。在我的图表中,我正在比较两条迹线。我使用了一条折线图,并且这两条迹线都用不同的颜色绘制。

plot "delay_try1.dat" using 1:2 title 'With CloneScale' with lines, \
     "normal_2.dat" using 1:2 title "Without CloneScale" with lines lc rgb "black", \
     "normal2.dat" using 1:2 title 'Without CloneScale' with lines lc rgb "black"

使用这个绘图命令,我在图例中得到了3个标题,其中有2个是重复的。我只想要出现2个标题并移除重复的一个。这是否可能实现?


你正在使用3个标题(1个用于“With CloneScale”,2个用于“Without CloneScale”)在plot命令中。你只能对“Without CloneScale”使用一个标题。但图例将仅显示2种类型的图形,而不是实际的三种。 - Neo
是的,我希望显示所有的图形,但只有两个图例。 - sethu
3个回答

61
为了实现这一点,您应该使用notitle标签。
plot "delay_try1.dat" using 1:2 title 'With CloneScale' with lines, "normal_2.dat" using 1:2 title "Without CloneScale" with lines lc rgb "black", "normal2.dat" using 1:2 with lines lc rgb "black" notitle

或者一个更一般的例子;

plot 'File.dat' using 1:2 notitle

notitle等价的替代方法是将title设置为空字符串。

plot 'File.dat' using 1:2 title ""

5
如果未命名的行比有标题的行多,使用set key noautotitle默认禁用标题更方便:
set key noautotitle

plot "delay_try1.dat" using 1:2 title 'With CloneScale' with lines, \
     "normal_2.dat" using 1:2 title "Without CloneScale" with lines lc rgb "black", \
     "normal2.dat" using 1:2 with lines lc rgb "black"

-2

如果您不介意一些诡计:

只需省略最后一个“Without CloneScale”标题,即可从图例中删除标题和线条。 将最后一个标题设置为空格将在图例中显示该线条,但似乎没有任何内容在其前面:

plot "delay_try1.dat" using 1:2 title 'With CloneScale' with lines,"normal_2.dat" using 1:2 title "Without CloneScale" with lines lc rgb "black", "normal2.dat" using 1:2 title ' ' with lines lc rgb "black"

省略最后一个标题会导致gnuplot生成一个默认标题,这很少是理想的。而且,让线条在图例中出现但没有文本似乎也不太理想。 - hertzsprung

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接