我需要在 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}
谢谢