Is there a way to change the order of the entries in the key/legend of gnuplot WITHOUT changing the plot command? (I do not mean reversing the entries)
I have multiple lines in one graph and the graphs are automatically generated for a wide range of different input data. I want to have the key entries sorted by their value on the far left of the graph. Changing the plot command is not possible, because this would have to be done for each graph individually.
As stated HERE, the key
can only be reversed
with
set key reverse
Unfortunately, AFAIK a reordering of the key is not possible.
It is possible. What I do is this: The first half of my plot command are the normal plot commands for the lines I want to have in the order I want them. But with the option 'notitle' on each line. The second half of my plot command plot basically empty lines, but with titles in the order I want them to show in the key, of course with the same styles as the plotted lines.
Example code:
DataFile using 1:4 notitle with lines ls 3,\
'' using 1:2 notitle with lines ls 1,\
'' using 1:3 notitle with lines ls 2,\
EmptyFile title "One" with lines ls 1,\
'' title "Two" with lines ls 2,\
'' title "Three" with lines ls 3
Can't remember atm if my EmptyFile contains nothing or just a set of data that is definitely outside my graph area.
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