Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gnuplot: Second legend in multiplot behind the grid

Tags:

plot

gnuplot

I'm using a multiplot with two boxes for two sets of data as legend. However, I came across the following problem: when using a grid, the second box is always behind the grid. Using the following code (borrowed from another question in SE and modified):

set term pngcairo
set output "legends.png"

set multiplot

# make a box around the legend
set key box

# fix the margins, this is important to ensure alignment of the plots.
set lmargin at screen 0.15
set rmargin at screen 0.98
set tmargin at screen 0.90
set bmargin at screen 0.15

set xrange[0:2*pi]
set yrange[-1:1]

set grid

# main plot command
plot sin(x) title "sinus"

# turn everything off
unset xlabel     #label off
unset ylabel
set border 0      #border off
unset xtics       #tics off
unset ytics
#unset grid        #grid off

set key at graph 0.5, 0.5
plot cos(x) ls 2 lw 2 title "cosinus"

The output you get is: enter image description here

I would like the second box to be opaque to the grid, just like the first one. The command #unset grid doesn't do anything since there is no grid if you disable xtics and ytics.

like image 905
Nister Avatar asked Apr 21 '26 17:04

Nister


1 Answers

Use opaque at the second key:

...
set key at graph 0.5, 0.5
set key opaque
....
like image 103
Tom Solid Avatar answered Apr 28 '26 02:04

Tom Solid