1

I have a plot with a linear line that links up several markers. The legend entry thus display the marker with a line through it.

Is there a way for the legend entry to display the marker only, without the line through it? i.e., as if it is a legend entry for no line plotting?

Thanks guys.

\begin{tikzpicture}
\begin{axis}[
legend pos=outer north east,
legend cell align={left},
legend entries={abc, def},
scatter/classes={
abc={mark=*,blue},
def={mark=diamond*,red},% <-- don’t add comma
},
]

\addplot [scatter, blue,
point meta=explicit symbolic,
]table [meta=algorithm] {
x y algorithm
50  327 abc
100 659 abc
};
\addplot [scatter, red,
point meta=explicit symbolic,
]table [meta=algorithm] {
x y algorithm
50  172 def
100 308 def
};
\end{axis}
\end{tikzpicture}
1
  • Please add a minimal working example (MWE) of your current code.
    – epR8GaYuh
    Oct 29, 2019 at 9:41

1 Answer 1

2

I found the answer, by adding 'only marks' to the legend setting. The plots still has a line, but it shows only marker in the legend.

\begin{tikzpicture}
\begin{axis}[
legend pos=outer north east,
legend cell align={left},
legend entries={abc, def},
scatter/classes={
abc={mark=*,blue, only marks},
def={mark=diamond*,red},% <-- don’t add comma
},
]

\addplot [scatter, blue,
point meta=explicit symbolic,
]table [meta=algorithm] {
x y algorithm
50  327 abc
100 659 abc
};
\addplot [scatter, red,
point meta=explicit symbolic,
]table [meta=algorithm] {
x y algorithm
50  172 def
100 308 def
};
\end{axis}
\end{tikzpicture}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .