This is a follow-up question to Using \pgfplotsinvokeforeach to create rows in a matrix of nodes. Consider the minimal working example below:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17, filter discard warning=false}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot {2*x + 1};
\label{myPlotA}
\addplot {3*x + 3};
\label{myPlotB}
\addplot {x + 3};
\label{myPlotC}
\matrix (myMatrix) [ matrix of nodes, at={(4,-5)} ] {
\foreach\myletter in {A,B,C}{
\ref{myPlot\myletter} \myletter
} \
%\ref{myPlotA} A \
%\ref{myPlotB} B \
%\ref{myPlotC} C \
};
\end{axis}
\end{tikzpicture}
\end{document}
As written, the output looks like this
but I am interested in producing the behavior given in the commented portion, i.e., output that looks like this
in an automated way using \foreach or a similar command. I run into trouble because inserting the \\ needed to break between matrix rows causes a compilation error inside of the \foreach loop.