I am trying to move the legend of a plot in gnuplot
partially outside the plot area. It seems however that the plot border is visible inside the legend, even if I set the legend property to opaque
.
A minimum example showing the problem:
#!/usr/bin/gnuplot -persistent
set key at 11,1.02 box opaque
plot sin(x)/x
So, I wonder how I should go about in order to make the entire interior of the key opaque white? I've thought about putting a white rectangle behind it, but it seems to be a kind of dirty solution.
The opaque
option of the key does indeed draw a white rectangle, but the border is drawn on top of the key. Use set border back
to draw the border behind the key:
set key at 11,1.02 box opaque
set border back
plot sin(x)/x
There isn't an option to set the key color directly; people tend to resort to either drawing a box under the key (as you were thinking) or more complicated methods.
One workaround is to get rid of the plot border for the top and right edges of the plot (since the information there is redundant anyway):
set border 3
set tics nomirror
plot sin(x)/x
Another possibility is simply moving the key--does it need to be right on the edge of the plot? It could be further inside or outside.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With