Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Simple question:

I can’t seem to control the z-order (i.e. which comes in front, which comes in the back) of the plots in a 2D axis.

MWE:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
  \begin{axis}
    \addplot+[only marks] table {
      0 2
      1 1
      2 2
    };
    \addplot+[mark=none, line width=2pt] table {
      0 2
      1 1
      2 2
    };
  \end{axis}
\end{tikzpicture}
\end{document}

Obligatory screenshot:

screenshot

The problem here is that the first plot, only marks always comes in front of the other plot. If I reverse the order of the respective \addplot commands then the colours and marks are switched but not the order of the plots. That is, the only marks are still in front of the line.

How can I change this?

(Yes, I need two separate plots here since the line will actually be a regression curve that uses different data but there is a huge overlap and the curve is barely visible below the point cloud).

share|improve this question
    
That even ignores the pgfonlayer environment! –  Caramdir Feb 12 '11 at 1:49
add comment

1 Answer

up vote 7 down vote accepted

It works if you set the option clip marker paths:

\begin{axis}[clip marker paths=true]

That might actually be an unintended side effect of the option.

share|improve this answer
    
So we may assume that it’s a bug then? Anyway, thanks. –  Konrad Rudolph Feb 12 '11 at 12:00
    
I think you should just ask Christian directly. Maybe he is willing to implement a documented option to control the z-order of markers. –  Philipp Feb 12 '11 at 12:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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