# pgfplots - more symbols in same legend line (with same legend text)

I have the following PGFPlots (mini sample).

\documentclass[11pt, a4paper, twoside]{scrreprt} % [11pt, parskip]{scrartcl}
\usepackage[utf8]{inputenc}

\usepackage{tikz}       % Zeichnungen
\usepackage{pgfplots}   % Diagramme

\begin{document}
\begin{tikzpicture}
\begin{axis}[
scatter/classes={a={blue},b={mark=triangle*,blue},c={mark=square*,blue}},
every x tick scale label/.style={at={(xticklabel cs:1)},anchor=south west},
every axis plot/.append style={mark=none} ,
legend pos=north east,
legend style={draw=none, fill=none},
]
\addplot [scatter, only marks, scatter src=explicit symbolic]
coordinates{
(1,1) [a]
(1,2) [b]
(1,3) [c]
(2,2) [a]
};
coordinates{
(1,1)
(2,2)
};
\legend{~,~,Data,Fit}
\end{axis}
\end{tikzpicture}
\end{document}


I want now a legend of the following style (one liner):
standard mark, triangle, square Data

I've updated the sample cause I got new some new information that I also have to put a Fit into the data. In the picture you can find an example of how I'd like my legend to look like.

• I am not sure if I have understood your question right, but are you searching for legend columns=-1? Sep 23 '18 at 19:34
• That kinda works yes, But I have to change the legend command to \legend{~,~,Data}. But now there is the next problem, I found out now, that I also have to draw a line into this plot. So I also need a Legend entry therefore. I'd need now a 3x2 Matrix where the first 2 entrys in the second line are empty. Sep 23 '18 at 19:52
• Could you perhaps include everything that you found out in your question? I am particularly curious about "that I also have to draw a line into this plot", which I do not understand. A cartoon showing what you'd like to achieve might also be advantageous.
– user121799
Sep 23 '18 at 20:28
• @marmot done. I've updated it and added a picture of how I want the legend. Sep 23 '18 at 20:36

One can always patch legends together using \addlegendentry and \addlegendimage. And on can come up with whatever legend image code one likes. Here is an example, certainly improvable. To find appropriate coordinates for the marks, I looked up the line legend code in the manual.

\documentclass[11pt, a4paper, twoside]{scrreprt} % [11pt, parskip]{scrartcl}
\usepackage[utf8]{inputenc}

\usepackage{tikz}       % Zeichnungen
\usepackage{pgfplots}   % Diagramme

\pgfplotsset{%
my legend/.style={legend image code/.code={%
\node[##1,anchor=west] at (0cm,0cm){\pgfuseplotmark{*}};
\node[##1] at (0.3cm,0cm){\pgfuseplotmark{triangle*}};
\node[##1,anchor=east] at (0.6cm,0cm){\pgfuseplotmark{square*}};
}},%
}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
scatter/classes={a={blue},b={mark=triangle*,blue},c={mark=square*,blue}},
every x tick scale label/.style={at={(xticklabel cs:1)},anchor=south west},
every axis plot/.append style={mark=none} ,
legend pos=north east,
legend style={draw=none, fill=none},
]

\addplot [scatter, only marks, scatter src=explicit symbolic]
coordinates{
(1,1) [a]
(1,2) [b]
(1,3) [c]
(2,2) [a]
};