PGFplots - 如何修改“线图例”样式

PGFplots - 如何修改“线图例”样式

我想知道是否可以更改默认图例样式line legend

对于我的其中一个文档,我尝试重新定义和协调(相同宽度等)我的图例样式(包括line legend),但是当我编译它时,我收到此错误消息:
Package pgfplots Error: This style is supposed to be constant.
并且未考虑到更改。

有沒有方法可以修改它?

\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}

相关内容