Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gnuplot key opaque background

Tags:

gnuplot

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.

like image 825
riklund Avatar asked Jul 20 '14 13:07

riklund


2 Answers

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

enter image description here

like image 129
Christoph Avatar answered Nov 11 '22 09:11

Christoph


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.

like image 20
andyras Avatar answered Nov 11 '22 09:11

andyras