Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gnuplot legend order

Tags:

gnuplot

Does somebody know how I can change the order within the key without changing the order of the plot commands? By default, the key has the same ordering as the titles of the individual plots.

For example: I plot first an error-band with filledcu, then the mean value as a solid line. Now I have the error-band title on top (in the key), followed by the title of the solid line. But I want to have it the other way round.

best wishes

like image 655
Raphael Roth Avatar asked May 16 '12 08:05

Raphael Roth


2 Answers

There's no way that I know of without resorting to ugly hacks... Here's one such ugly hack:

plot sin(x) with filledcurves notitle, \
     cos(x) with lines, \
     NaN with filledcurves title 'sin(x)' lc rgb "#ff0000"

Basically, we plot the first two plots as normal (except we remove the title from the first plot). Then we make a "null" plot (plot NaN) with the same style and title that you want in the key...

like image 75
mgilson Avatar answered Nov 09 '22 15:11

mgilson


Just use

set key invert

to change the ordering of the key entries.

like image 34
Christoph Avatar answered Nov 09 '22 17:11

Christoph