gnuplot:图例被数据遮挡

8
我是gnuplot的新手,在绘制堆积直方图时,我发现图例被数据遮挡了。
有没有一种方法可以将图例放在数据上方?非常感谢您的帮助。 编辑:我目前正在使用“set key outside bottom”将图例放在外面,但这不是我想要的最佳解决方案。
2个回答

5

最近的版本允许将图例背景设置为白色:

set key opaque

这仅仅是在图例上添加白色背景,以使它出现在所有图形的顶部。在这篇帖子中找到了答案。


3
如果您更喜欢将键位放在数据顶部而不是完全在绘图框之外,这里有一个解决方法(以sin(10*x)为例):
set multiplot
unset key
plot sin(10*x) # this will plot with tics and a border, but no key
set key box
unset tics
unset border
bignumber=10 # make this number larger than the y range so the line will not be seen
plot [][0:1] bignumber title 'sin(10*x)' # this will just plot the key with the title
unset multiplot

使用这种方法,首先您需要绘制数据/函数图,然后在其上创建一个仅带有键的图。您必须确保正确设置第二个图的标题。

1
谢谢你提供的解决方案,但这不是一种更好的方法吗?Gnuplot肯定有办法在没有使用multiplot技巧的情况下将图例绘制在所有数据之上,对吧?我认为这并不是一个罕见的情况或特殊功能,...仍在寻找更好的解决方案... - Thomas Fankhauser
现在我已经年长而且更加聪明了,我学会了set key opaque命令,它可以在所有数据绘制完成后绘制键! - andyras

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