# [Tex/LaTex] Pgfplots: Legend with multiple columns and rows, different entry widths

legendpgfplotswidth

I have two data sets of five curves each that I want to display in one tikzpicture. The five curves of the first data set are solid lines, the five curves of the second data set are dashed.
In the legend, I want five entries for the curves (marks only) and two extra to distinguish between the data sets (lines only). Preferably the five curve entries get displayed in one row and the data set entries in a second row. If I do this like my code shows, the the first two columns of BOTH rows are automatically adjusted.

This looks ugly. Is there any way to…
…separately adjust the columns width of each legend row?
…adjust the width of all columns to a fixed width (that matches the width of the longest entry)?
…display the data set entries in a second legend?

I'd also prefer to keep the legend below the plot. Creating in east (outside) of the plot solves the problem but also results in a non-centered plot.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}

\begin{document}
\begin{tikzpicture}
\begin{axis}
[
ylabel={ylabel},
xlabel={xlabel},
xmin=0,
xmax=120,
ymin=0,
ymax=0.2,
legend columns = 5,
legend style = {at={(0.5, -0.23)}, anchor=north, inner sep=3pt, style={column sep=0.15cm}},       %vorher: at={(1.3, 1)}
legend cell align=left,
ticklabel style={
/pgf/number format/.cd,
fixed,
use comma,
}
]

\addlegendimage{black, only marks, mark=square} % or mark=none?

\addplot[color=black, mark=square, dashed, mark options={solid}] coordinates {(60,0.05)(30,0.18)};
\addplot[color=red, mark=star, dashed, mark options={solid}] coordinates {(60,0.05)(40,0.18)};
\addplot[color=orange, mark=triangle, dashed, mark options={solid}] coordinates {(60,0.05)(50,0.18)};
\addplot[color=green, mark=diamond, dashed, mark options={solid}] coordinates {(60,0.05)(60,0.18)};
\addplot[color=blue, mark=o, dashed, mark options={solid}] coordinates {(60,0.05)(70,0.18)};

\end{axis}
\end{tikzpicture}

\end{document}


This is an ad how way of wasting less space in your specific use case: add an empty column and pretend the long entries have zero width.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[
ylabel={ylabel},
xlabel={xlabel},
xmin=0,
xmax=120,
ymin=0,
ymax=0.2,
legend columns = 5,
legend style = {at={(0.5, -0.23)}, anchor=north, inner sep=3pt, style={column sep=0.15cm}},       %vorher: at={(1.3, 1)}
legend cell align=left,
ticklabel style={
/pgf/number format/.cd,
fixed,
use comma,
}
]

\addlegendimage{black, only marks, mark=square} % or mark=none?