Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gnuplot: legend gets hidden behind data

Tags:

legend

gnuplot

I am new to gnuplot and while plotting stacked histogram, I find that legend gets hidden behind the data.

Is there a method to put the legend above the data? Thanks a lot for your help. EDIT: I am currently using set key outside bottom to place legend outside, but that is not the best solution I would like.

like image 574
user984260 Avatar asked Feb 24 '12 15:02

user984260


2 Answers

Recent versions allow to make the background of the legend white:

set key opaque

This simply adds a white background to the legend so it appears on top of all graphs. Found the answer in this Post.

like image 102
Thomas Fankhauser Avatar answered Sep 26 '22 08:09

Thomas Fankhauser


If you would rather have the key on top of the data rather than the key outside the plot box altogether, here is one workaround (using sin(10*x) as an example):

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

Using this method, first you plot your data/function, then you create a plot on top of that which just has a key. You have to make sure to set the title of the second plot properly.

like image 30
andyras Avatar answered Sep 26 '22 08:09

andyras