Search code examples
gnuplot

bring legend to the front in gnuplot


Is there a way to bring the key (legend) in gnuplot (epslatex terminal) to the very front? In my plot I experience that some filledcurves are on top of the small line samples of the key so that these are invisible. The lables in the key are placed on top as they are drawn by latex. I know that I could change the order in the plot (filledcurves first) but I actually want that the filledcurves hide the previously drawn lines in the plot itself.


Solution

  • First plot your lines without the key plot x notitle ls 1, then plot your filledcurves, then plot yet the extra lines using the linestyles of the first lines, but so that they are out of the visible area:

    set yrange [-10:10]
    plot -x notitle ls 2, x**2/3-5 w filledc ls 5, x**2+100 t "first-line legend" ls 2 
    

    This gives you the legend at the top of the filledcurves, but the visible lines below. Hope this works with epslatex too.