Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to split the key in gnuplot?

Tags:

gnuplot

enter image description here

I have plotted this table in gnuplot. as you can see the key should be seperated in two parts. The first 4 keys should remain in their place but the rest 4 keys should move down so that they won't cross the data.

How can I split the key this way?

like image 628
SRYZDN Avatar asked Nov 09 '14 17:11

SRYZDN


1 Answers

One plot only supports a single key, so it can not be split. Also, all data is plotted by one single plot command, so you can not plot the first half of the data, change settings of the key and that plot the other half.

There are other ways to place the key, e.g. outside the plot area.

However, I have two workarounds:

Dummy plots

First, you can add dummy plots:

plot \
    sin(x), 
    "+" u 1:(NaN) title " " w dots linecolor rgb "white", 
    "+" u 1:(NaN) title " " w dots linecolor rgb "white", 
    cos(x) title "cosinus", 
    tan(x) title "tangens"

Due to the 1:(NaN), no data is plottet. The single dot in the legend is white, and the title is a white space. So, it looks like empty lines in the key:

enter image description here

Multiplot

The other solution is to create two plots using multiplot:

set xrange[...]
set yrange[...]
set multiplot
plot sin(x)
set key bottom right
plot cos(x) linetype 2
unset multiplot

note that you have to set the ranges explicitly here. Also, axes, tics and labels are drawn twice, which may look odd on some output formats. In this case, you can unset all of them before the second plot, so everything is drawn only once.

While this way is a bit more complicated, you have much more control over your key:

enter image description here

like image 138
sweber Avatar answered Oct 12 '22 00:10

sweber