I am forced to make rather small plots that need to have a legend. This means that it is unavoidable that part of the plot gets covered by the legend.
To retain legibility of the plot, I would like to make the background of the legend partly transparent. My approach was to use legend style={fill opacity=0.8, draw opacity=1}
, however, this makes the whole legend transparent, and not only the fill.
Here is an MWE:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width=5cm,
axis equal,
legend style={fill=white, fill opacity=0.6, draw opacity=1},
]
\addplot[samples=100, domain=0:2*pi, red]
({cos(deg(x))}, {sin(deg(x))});
\addlegendentry{test}
\end{axis}
\end{tikzpicture}
\end{document}
The output is:
As you can see the outline is fully drawn, but the text inside the legend is also transparent. How can avoid this, and only make the fill translucent?
Best Answer
You can add the key
to your
legend style
command.