Is it possible to customize the style of legend keys (the part of legend which indicates the line type being solid, dashed, dotted etc.)?
\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[domain=0:10, no marks]
\addplot+[red, solid] {x - 1}; \label{one}
\addplot+[blue, solid] {2*x - 3}; \label{two}
\addlegendentry{$m = 2$}
\addlegendentry{$m = 1$}
\addplot+[red, densely dotted] {x - 0}; \label{three}
\addplot+[blue, densely dotted] {2*x + 2}; \label{four}
% Rough look of desired legend
\draw[densely dotted, blue] (0, 11) -- (0.5, 11);
\draw[solid, blue] (0.5, 11) -- node[xshift=0.1cm, right] {$m = 1$} (1, 11);
\draw[densely dotted, red] (0, 13) -- (0.5, 13);
\draw[solid, red] (0.5, 13) -- node[xshift=0.1cm, right] {$m = 2$} (1, 13);
\end{axis}
\end{tikzpicture}
\end{document}
Instead of having a legend for each curve, I would like two legend entries which indicate the line slope $m$ for both solid and dashed lines. So, the legend entry $m = 2$ will be referenced by a red line segment, half of which is dashed and the other half solid. Something like \addlegendimage{custommarker, red}, perhaps. Is there a process in place for doing this?
This question is different in that I am interesting in creating a non-default legend key. The whole legend could be created from scratch, but wondering if there is an inbuilt way to do this (if default dimensions of legend boxes, white spaces etc could be easily extracted, perhaps from scratch would be simpler).

addplot+to pass through to the legend image, but removing the##1from the\drawcall doesn't seem to change anything... – mcmuffin6o Feb 22 '24 at 01:48