I would like to know if it's possible to change the default legend style line legend
.
For one of my documents, I'm trying to redefine and harmonize (same width, etc) my legend styles (including line legend
) but when I compile it, I get this error message:
Package pgfplots Error: This style is supposed to be constant.
and the change is not taken into account.
Is there a way to modify it?
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{
compat=newest,
/pgfplots/xbar legend/.style={
/pgfplots/legend image code/.code={
\draw [##1,/tikz/.cd,bar width=0.2em,yshift=-0.21em,xshift=-0.1em,bar shift=0pt]
plot coordinates {(0.6em,0em) (1em,2*\pgfplotbarwidth)
};}},
/pgfplots/ybar legend/.style={
/pgfplots/legend image code/.code={
\draw [##1,/tikz/.cd,bar width=0.2em,yshift=-0.31em,bar shift=0pt]
plot coordinates {(0em,0.3em) (2*\pgfplotbarwidth,0.8em) (4*\pgfplotbarwidth,0.5em)
};}},
/pgfplots/line legend/.style={
/pgfplots/legend image code/.code={
\draw [##1, mark repeat=2, mark phase=2, xshift=-0.1em, mark options={scale=0.70}]
plot coordinates {(0em,0em) (0.5em,0em) (1em,0em)
};}},
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[legend entries={\strut A,\strut B,\strut C,},legend columns=1]
\addplot+[ybar, ybar legend, mark=none, fill=red, draw=red!50!black]
coordinates {(10,5) (11,6)};
\addplot+[xbar, xbar legend, mark=none, fill=green, draw=green!50!black]
coordinates {(10,5) (11,6)};
\addplot+[mark=*]
coordinates {(10.5,5) (11.5,6)};
\end{axis}
\end{tikzpicture}
\end{document}