TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.



    \addplot+[only marks] table {
      0 2
      1 1
      2 2
    \addplot+[mark=none, line width=2pt] table {
      0 2
      1 1
      2 2

Obligatory 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
up vote 11 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

Your Answer


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.