[Tex/LaTex] pgfplots adding unwanted dashed lines

pgfplotstikz-pgf

I'm using pgfplots to plot multiple lines, but after a certain number of lines, they seem to revert to dashed lines regardless of line style.

enter image description here

Is there a way to fix this? The code to generate the figure is attached:

\documentclass[10pt]{article}

\usepackage{pgfplots}
\definecolor{markercolor}{RGB}{124.9, 255, 160.65}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}
\addplot+[color=magenta,mark=*,semithick, mark options={solid,fill=markercolor}]
coordinates{(1,1)(2,2)(3,3)(4,4)(5,5)};
\addplot+[color=magenta,mark=square*,semithick, mark options={solid,fill=markercolor}]
coordinates{(1,2)(2,4)(3,6)(4,8)(5,10)};
\addplot+[color=black,mark=*,semithick, mark options={solid,fill=markercolor}]
coordinates{(1,3)(2,6)(3,9)(4,12)(5,15)};
\addplot+[color=black,mark=square*,semithick, mark options={solid,fill=markercolor}]
coordinates{(1,4)(2,8)(3,12)(4,16)(5,20)};
\addplot+[color=red,mark=*,semithick, mark options={solid,fill=markercolor}]
coordinates{(1,5)(2,10)(3,15)(4,20)(5,25)};
\addplot+[color=red,mark=square*,semithick, mark options={solid,fill=markercolor}]
coordinates{(1,6)(2,12)(3,18)(4,24)(5,30)};

\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

Best Answer

mark options only affects the marks - not the style of the lines. \addplot+ adds options to those which would be used by \addplot, which would default to cycling through line styles, colours etc. So only options you explicitly override don't take effect. If you don't want the options to be appended, use \addplot[<options>] instead. For example:

\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\definecolor{markercolor}{RGB}{124.9, 255, 160.65}
\begin{document}
\begin{tikzpicture}
  \begin{axis}
    \addplot[color=magenta,mark=*,semithick, mark options={solid,fill=markercolor}]
    coordinates{(1,1)(2,2)(3,3)(4,4)(5,5)};
    \addplot[color=magenta,mark=square*,semithick, mark options={solid,fill=markercolor}]
    coordinates{(1,2)(2,4)(3,6)(4,8)(5,10)};
    \addplot[color=black,mark=*,semithick, mark options={solid,fill=markercolor}]
    coordinates{(1,3)(2,6)(3,9)(4,12)(5,15)};
    \addplot[color=black,mark=square*,semithick, mark options={solid,fill=markercolor}]
    coordinates{(1,4)(2,8)(3,12)(4,16)(5,20)};
    \addplot[color=red,mark=*,semithick, mark options={solid,fill=markercolor}]
    coordinates{(1,5)(2,10)(3,15)(4,20)(5,25)};
    \addplot[color=red,mark=square*,semithick, mark options={solid,fill=markercolor}]
    coordinates{(1,6)(2,12)(3,18)(4,24)(5,30)};
  \end{axis}
\end{tikzpicture}
\end{document}

gives

solid lines

Or, for the same result with less hassle:

\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage{pgfplots}
\pgfplotsset{%
  compat=1.13,
  every axis plot/.append style={semithick, mark options={solid,fill=markercolor}}
}
\definecolor{markercolor}{RGB}{124.9, 255, 160.65}
\begin{document}
\begin{tikzpicture}
  \begin{axis}
    \addplot [color=magenta ,mark=*]
    coordinates{(1,1)(2,2)(3,3)(4,4)(5,5)};
    \addplot [color=magenta, mark=square*]
    coordinates{(1,2)(2,4)(3,6)(4,8)(5,10)};
    \addplot [color=black, mark=*]
    coordinates{(1,3)(2,6)(3,9)(4,12)(5,15)};
    \addplot [color=black, mark=square*]
    coordinates{(1,4)(2,8)(3,12)(4,16)(5,20)};
    \addplot [color=red, mark=*]
    coordinates{(1,5)(2,10)(3,15)(4,20)(5,25)};
    \addplot [color=red, mark=square*]
    coordinates{(1,6)(2,12)(3,18)(4,24)(5,30)};
  \end{axis}
\end{tikzpicture}
\end{document}