Search code examples
gnuplot

Gnuplot making transparent background for key


I need a transparent background for my plot key so that grid lines remain visible. However, you may see that there is a white overlay below the entry of the key which seem to be drawn on top of the grid.

Resulting graph

Here is the code creating picture above:

set terminal png size 512,512;
set output 'key.png';
set grid;
set key Left reverse nobox;
plot [0:3] sin(x) with line title "Sine wave", [0:3] cos(x) with line title "Cosine wave";

Solution

  • That's the way the program is designed. The grid is masked so that it doesn't occlude the key area.

    I think the simplest way to get what you ask for is to place the titles explicitly rather than auto-generating the key:

    set xtics 1
    set ytics .1
    set grid lt 1 lw 0.5 lc "black" dashtype "."
    
    plot sin(x)/x   lw 2 title at graph 0.9,0.9,  \
         sin(2*x)/x lw 2 title at graph 0.9,0.85
    

    enter image description here