![带有 tikz 的图表中的图例](https://linux22.com/image/274677/%E5%B8%A6%E6%9C%89%20tikz%20%E7%9A%84%E5%9B%BE%E8%A1%A8%E4%B8%AD%E7%9A%84%E5%9B%BE%E4%BE%8B.png)
我需要在 TikZ 中为我的图表制作图例,但我需要该图例由 3 列组成,我该怎么做?
我使用这个代码:
\newenvironment{customlegend}[1][]{%
\begingroup
\csname pgfplots@init@cleared@structures\endcsname
\pgfplotsset{#1}%
}{
\csname pgfplots@createlegend\endcsname
\endgroup
}%
\def\addlegendimage{\csname pgfplots@addlegendimage\endcsname}
\pgfkeys{/pgfplots/number in legend/.style={%
/pgfplots/legend image code/.code={%
\node at (0.125,-0.0225){#1}; % <= changed x value
},%
},
} \pgfplotsset{ every legend to name picture/.style={west} }
------
\begin{customlegend}[legend cell align=left, %<= to align cells
legend entries={ % <= in the following there are the entries
ac, csv },
legend style={at={(-1,-9)},font=\tiny}] % <= to define position and font legend
% the following are the "images" and numbers in the legend
\addlegendimage{->,dash
pattern=on 4pt off 2pt on 4pt off 2pt on 4pt off 2pt on 1pt off
2pt,black!40!red,very thick}
\addlegendimage{->,dash pattern=on 4pt off 2pt on 4pt off 2pt on 4pt off
2pt on 1pt off 2pt,olive!30!purple,very thick}
\end{customlegend}
谢谢