I got a legend with two rows and I would like to have a different alignment on each row. Is it possible ?
In my current code, the legend entries on the second line are much longer than ones on the first line. This results in extra space between 1st line legend entries and I would like to avoid that. Here is my code :
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\begin{semilogyaxis}[xmin=0, xmax=600, ymin=1e-1, ymax=1e7, axis x line*=bottom, axis y line*=left, xlabel={X}, ylabel={Y},width=0.9\textwidth, height=0.5\textwidth, legend columns=3, legend style={cells={anchor=west}, at={(1,0.3)}, anchor=east}]
\addplot [color=red, domain=0:600, samples=1000, thick, mark=none] {(1+4*x^2) };
\addlegendentry{A}
\addplot [color=blue, domain=0:600, samples=1000, thick, mark=none] {1+2*x };
\addlegendentry{B}
\addplot [color=green!80!black, domain=0:600, samples=1000, thick, mark=none] {1.};
\addlegendentry{C}
\addlegendimage{black, thick}
\addlegendentry{Numerical}
\addlegendimage{black, ultra thick, loosely dashed}
\addlegendentry{Analytical}
\addplot[color=red, domain=0:600, loosely dashed, samples=1000, ultra thick] {(1+4*x^2) };
\addplot[color=blue, domain=0:600, loosely dashed, samples=1000, ultra thick] {1+2*x };
\addplot[color=green!80!black, domain=0:600, loosely dashed, samples=1000, ultra thick] {1.};
\end{semilogyaxis}
\end{tikzpicture}
\end{figure}
\end{document}
Thanks !
matrix of nodesso changing the number of columns from line to line is not possible.legend columns=-1would put all entries in one row, which might be more appropriate for you. – Andrew Swann Jul 08 '14 at 08:09