2

Convince yourself about the color and image of the marker and line (where there should only be one at the time). Effectively the color and marker/line stay at the default value even though specified differently.

What am I doing wrong or is it a bug?

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[legend style={at={(0.2,0.5)},anchor=north}]
\addplot table[col sep=comma, color=red, only marks] {
0,2
2,4
5,5
};
\addlegendentry{A};
\addplot table[col sep=comma, color=red, mark=none] {
0,2.4
5,5.4
};
\addlegendentry{Fit A};
\end{axis}
\end{tikzpicture}

\end{document}

Both traces are supposed to be red and one without marker and the other without line but the legend shows both.

Both traces should be red.

5

It is no bug, you are just putting the directives at the wrong place.

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

\begin{document}

\begin{tikzpicture}
\begin{axis}[legend style={at={(0.2,0.5)},anchor=north}]
\addplot[color=red, only marks] table[col sep=comma] {
0,2
2,4
5,5
};
\addlegendentry{A};
\addplot[color=red, mark=none] table[col sep=comma] {
0,2.4
5,5.4
};
\addlegendentry{Fit A};
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.