# Despite using the 'no markers' option, I still get plotmarks in my legend. Why?

Nice to finally post a question myself after finding solutions to my problems on numerous occasions within these forums. I hope someone can be of help (and that this hasn't been asked already).

The problem is as follows: I'm using pgfplots for the plots within my document. I used the procedure described in section 4.8.7 (Legends outside of an axis) within the pgfplots manual in order to create one legend for several horizontally aligned plots. In general this works fine. My issue is, that the marker style differs between the plot and the legend. I am using the no markers option with \addplot. The legend shows the correct line style but also markers. Is it possible to remove the markers? Did I place the ref{} command to reference the legend in the wrong place? I couldn't find any solution by browsing google or within the manual, hence my question.

The code looks as follows (I can post a minimum working example if necessary):

\begin{figure}[htb]
\centering
\begin{tikzpicture}[baseline]
\begin{axis}
[
legend columns=-1,
legend entries={$Pe_{ax} = 1$;,$Pe_{ax} = 10$;,$Pe_{ax} = 100$;,$Pe_{ax} = 1000$},
legend to name=named3,
width=6cm, height=6cm,
xmin={0},
xmax={2},
ymin={0},
ymax={2},
xtick={0,1,2},
ytick={0,2},
xlabel= {$\Theta [-]$},
ylabel={$E(\Theta) [-]$},
label style={font=\footnotesize},
tick label style={font=\footnotesize},
legend style={draw=none}
]
\addplot+[no markers,smooth, color=black, dashed] coordinates {(1,0) (1,2)};
\addplot+[no markers,smooth, color=black, dotted] table[x=X,y=Y1] {Tabellen/Butt_1999_Bo1.txt};
\addplot+[no markers,smooth, color=black, dashdotdotted] table[x=X,y=Y1] {Tabellen/Butt_1999_Bo10.txt};
\addplot+[no markers,smooth, color=black, dashdotted] table[x=X,y=Y1] {Tabellen/Butt_1999_Bo100.txt};
\addplot+[no markers,smooth, color=black, solid] table[x=X,y=Y1] {Tabellen/Butt_1999_Bo1000.txt};
\end{axis}
\end{tikzpicture}
\hspace{0cm}
\centering
\begin{tikzpicture}[baseline]
\begin{axis}
[
width=6cm, height=6cm,
xmin={0},
xmax={2},
ymin={0},
ymax={1},
xtick={0,1,2},
ytick={0,1},
xlabel= {$\Theta [-]$},
ylabel={$F(\Theta) [-]$},
label style={font=\footnotesize},
tick label style={font=\footnotesize}
]
\addplot+[no markers,smooth, color=black, dashed] coordinates {(1,0) (1,1)};
\addplot+[no markers,smooth, color=black, dotted] table[x=X,y=Y2] {Tabellen/Butt_1999_Bo1.txt};
\addplot+[no markers,smooth, color=black, dashdotdotted] table[x=X,y=Y2] {Tabellen/Butt_1999_Bo10.txt};
\addplot+[no markers,smooth, color=black, dashdotted] table[x=X,y=Y2] {Tabellen/Butt_1999_Bo100.txt};
\addplot+[no markers,smooth, color=black, solid] table[x=X,y=Y2] {Tabellen/Butt_1999_Bo1000.txt};
\end{axis}
\end{tikzpicture}
\ref{named3}
\caption{Text.}
\end{figure}


Hope this helps! Thanks in advance for any ideas, thoughts and the like!

Edit: as requested here is a minimum working example of the problem.

\documentclass[12pt,a4paper]{article}
\usepackage{pgfplots}
\begin{document}
\begin{figure}[htb]
\centering
\pgfplotsset{domain=-1:1}
\begin{tikzpicture}[baseline]
\begin{axis}
[
legend columns=-1,
legend entries={$x^2$;,$x^3$;,$x^4$;,$x^5$},
legend to name=named,
width=6cm, height=6cm,
xlabel= {$x$},
ylabel={$f(x)$},
legend style={draw=none}
]
\end{axis}
\end{tikzpicture}
\hspace{0cm}
\centering
\begin{tikzpicture}[baseline]
\begin{axis}
[
width=6cm, height=6cm,
xlabel= {$x$},
ylabel={$f'(x)$},
]
\end{axis}
\end{tikzpicture}
\ref{named}
\caption{Minimum working example.}
\end{figure}
\end{document}

-
Welcome to TeX.SX! –  Heiko Oberdiek Aug 24 '13 at 23:10
As you're not using any markers, you could just add no markers as an option to the axis, this also removes them from the legend. Would that be good enough? I cannot explain why the problem occurs. –  Torbjørn T. Aug 24 '13 at 23:29
Please make your code compilable, starting with \documentclass{...} and ending with \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to help you. Help them help you: remove that one hurdle between you and a solution to your problem. –  Jubobs Aug 24 '13 at 23:51
@HeikoOberdiek Thanks a lot! Somehow my initial greeting wasn't posted so...good morning everybody! –  Tovja Aug 25 '13 at 6:42
@TorbjørnT. I tried to do so (as explained below) but that doesn't solve the problem. The legend disappears completely except for the legend text and is put in a strange position. –  Tovja Aug 25 '13 at 6:42

Note: I'm assuming you're using pgfplots v1.8.

You're passing the no markers option to \addplot+, but no markers is an option available for the axis environment, not for \addplot commands. That's likely the problem.

no markers (assuming it is passed to axis) does exactly what you want, i.e. disable all plotmarks on all the graphs within that axis environment; Torbjørn T.'s comment is sound.

\begin{axis}[no markers,...]
...
\end{axis}


To disable markers on a given \addplot (or \addplot+), you can pass the mark=none option to that command.

\begin{axis}[...]
...
\end{axis}


However, neither

\addplot+[no markers,...] ... ;


nor

\begin{axis}[mark=none,...]
...
\end{axis}


will produce the desired result, as your MWE demonstrates.

References:

(following a conversation with percusse)

Revision 1.8 (2013/03/17) of the pgfplots manual also makes one reference (in the last code sample of section 5.8.1) to a no marks option for \addplot, but this option is documented nowhere in the manual. Perhaps the maintainer can shed some light on the matter if he finds this post, but for now, it's safe to assume that the no marks option has become obsolete and that it's probably best not to use it from now on.

Edit: the following code produces the desired output for me.

\documentclass[12pt,a4paper]{article}
\usepackage{pgfplots}
\begin{document}
\begin{figure}[htb]
\centering
\pgfplotsset{domain=-1:1}
\begin{tikzpicture}[baseline]
\begin{axis}
[
legend columns=-1,
legend entries={$x^2$;,$x^3$;,$x^4$;,$x^5$},
legend to name=named,
width=6cm, height=6cm,
xlabel= {$x$},
ylabel={$f(x)$},
legend style={draw=none},
no markers,
]
\end{axis}
\end{tikzpicture}
\hspace{0cm}
\centering
\begin{tikzpicture}[baseline]
\begin{axis}
[
width=6cm, height=6cm,
xlabel= {$x$},
ylabel={$f'(x)$},
no markers,
]

Thanks for the rapid answers! Indeed, I'm using pgfplots v1.8. So far, using no markers with the axis environment worked fine with me. Usually the legend entries are in accordance with the plot. I tried to remove the no markers option from the line featuring \addplot+[...] and adding it instead to \begin{axis}[...]. The result looks even stranger. The legend entries are put in a rather random position next to the plot without markers or line styles, just plain text. –  Tovja Aug 25 '13 at 6:34
Now I see my mistake. I added the option no markers to the axis environment to a new set of [...] instead of simply adding it to the existing one. No wonder it did not work. –  Tovja Aug 25 '13 at 12:52