Assumed we have the following MWE to display various graphs in one single diagram.
Minimum working example (MWE):
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest, scale only axis}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis y line* = left,
legend style = {at={(0.5,-0.125)},
anchor = north,
legend columns = 3,
/tikz/every even column/.append style = {column sep=0.5cm},
/tikz/every odd column/.append style = {column sep=0.15cm},
},
]%
\addplot coordinates {(0,0) (1,1)};
\legend{Graph 1};
\end{axis}%
%
\begin{axis}[
axis x line = none,
axis y line* = right,
legend style = {at={(0.5,-0.125)},
anchor = north,
legend columns = 3,
/tikz/every even column/.append style = {column sep=0.5cm},
/tikz/every odd column/.append style = {column sep=0.15cm},
},
]%
\addplot coordinates {(0,1) (1,0)};
\addplot coordinates {(0,0.5) (1,0.5)};
\legend{Graph 1, Graph 2};
\end{axis}%
%
\begin{axis}[
axis x line = none,
axis y line* = right,
legend style = {at={(0.5,-0.125)},
anchor = north,
legend columns = 3,
/tikz/every even column/.append style = {column sep=0.5cm},
/tikz/every odd column/.append style = {column sep=0.15cm},
},
]%
\pgfplotsset%
{%
every outer y axis line/.style = {xshift=2cm},
every tick/.style = {xshift=2cm},
every y tick label/.style = {xshift=2cm},
}%
\addplot coordinates {(0.5,0) (0.5,1)};
\legend{Graph 4};
\end{axis}%
\end{tikzpicture}
\end{document}
Screenshot of the result:
Description of the issue:
As you can see, the legends are looking very ugly. How can I adjust the legends centered below the plot?
Update:
I've posted a further question about how to align the legend items in two rows or columns to let them appear nicely.



legend columns = 3does not work anymore. I think this command is not usable anymore with your solution, right? – Dave Mar 19 '19 at 15:13