# pgfplots axis clipping large markers

In the example below the large markers at the axes are drawn over the axes.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document}

\begin{tikzpicture}[baseline]

\begin{axis}[xmin=0, xmax=1, ymin=0, ymax=1, clip=true]

coordinates {
(0.0, 0)
(0.2, 1)
(0.4, 0.8)
(0.6, 0)
(0.8, 0)
(1.0, 0)
};

\end{axis}

\end{tikzpicture}

\end{document}


Instead I would like the axes to clip the parts of the markers that leave the axis box area. Also, I would prefer the axis and the axis ticks drawn over the marks. It should like this then:

Is this possible?

You can use clip marker paths=true instead of clip=true and add axis on top=true (thanks @Jake for the suggestion) in order to get the axes and the axes ticks drawn in the foreground.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document}

\begin{tikzpicture}[baseline]

\begin{axis}[xmin=0, xmax=1, ymin=0, ymax=1, clip marker paths=true, axis on top=true]

coordinates {
(0.0, 0)
(0.2, 1)
(0.4, 0.8)
(0.6, 0)
(0.8, 0)
(1.0, 0)
};

\end{axis}

\end{tikzpicture}

\end{document}


• +1 And you might want to add axis on top to address the OP's final request. – Jake Sep 26 '13 at 16:23
• @Jake Oh thanks. I totally forgot about that. – Philipp Sep 26 '13 at 16:26
• @user24520: Yeah, that's possible using set layers. I thought we had a question about that that I could refer you to, but it doesn't seem like it. Could you open a new question that asks specifically about that (it's not really directly related to this question about clipping markers)? That would help other people who come across the same problem. – Jake Sep 26 '13 at 16:42
• Thanks, that is exactly what I looked for. But if I use axis on top in combination with the clipping also the grid lies before the marks. I found a solution for that under: [link] tex.stackexchange.com/questions/14458/… – user24520 Sep 26 '13 at 16:43
• @user24520 That's good. I tried something with layers but couldn't get it to work the way I wanted. That a solution to your problem could already be found on this site supports my suspicion that every possible piece of knowledge must already be here somewhere :) – Philipp Sep 26 '13 at 16:55