I have a legend with the option area legend to draw a little rectangle in the legend instead of a line segment. There is a border around the rectangle I would like to either remove or make the same color as the actual rectangle. How is this done?

  • How do you want some help? You didn't even provide any of the command used to draw this area! Feb 25, 2013 at 13:55
  • the command is area legend Feb 25, 2013 at 13:55
  • It does not: \addplot +[fill=grey0, draw=none] Feb 25, 2013 at 13:58
  • @ManofOneWay using your command gives me "undefined control sequence" Feb 25, 2013 at 13:59

2 Answers 2


To hide the border both in the plot and in the legend, you should use draw opacity=0 in the \addplot options instead of draw=none:

\documentclass[border=5mm] {standalone}


\addplot [fill=yellow,draw opacity=0, area legend] coordinates {(0,0) (2,1) (4,1)} \closedcycle;


Another possibility is to change the area legend style so that draw=none actually takes effect. (Example taken from the pgfplots manual, page 173.)


    /pgfplots/area legend/.style={%
        /pgfplots/legend image code/.code={%
            \fill[##1] (0cm,-0.1cm) rectangle (0.6cm,0.1cm);
    area legend,
    axis x line=bottom,
    axis y line=left,
    legend style={at={(0.03,0.97)},anchor=north west},
    axis on top,xmin=0]
    pattern=crosshatch dots,
    pattern color=blue,
    samples=500] {sqrt(x)} \closedcycle;
    pattern color=blue!30!white,
    draw=blue!30!white] {x^2} \closedcycle;
\addplot[red,line legend] coordinates {(0,0) (1,1)};
\legend{$\sqrt x$,$x^2$,$x$}


enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.