我想让图例边框更紧密。\begin{axis}[legend style={...}]
调整图例边框(边框的宽度和高度)的属性是什么?
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
xlabel={XLABEL},
ylabel={YLABEL},
legend columns=-1]
\addplot+[mark=none] plot {x^2};
\addlegendentry{a}
\addplot+[mark=none] plot {1};
\addlegendentry{b}
\addplot+[mark=none] plot {x};
\addlegendentry{c}
\end{axis}
\end{tikzpicture}
\end{document}
答案1
您可以使用图例样式选项,如下所示:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
xlabel={XLABEL},
ylabel={YLABEL},
legend style={inner xsep=0pt, inner ysep=0pt},
legend columns=-1]
\addplot+[mark=none] plot {x^2};
\addlegendentry{a}
\addplot+[mark=none] plot {1};
\addlegendentry{b}
\addplot+[mark=none] plot {x};
\addlegendentry{c}
\end{axis}
\end{tikzpicture}
\end{document}