2

It seems like pgfplots draws the grid after the axis lines. Therefore light grey grid lines appear on top of the axis lines. This is what I mean: enter image description here See the light lines separating the axis lines. I guess there is some sort of "draw this after that" solution, similar to: this topic, however I was not able to achieve the desired behaviour (axis line on top).

This should be specific to all 3D plots. Is there a concise way to adress only 3D plots?

 axis lines=box, % left, right, center, box, none outer axis line style={line width=5pt,}, axis line on top/.style={axis on top=true,}, % doesnt work as expected 

A minimal working example is

\documentclass{standalone} \usepackage{tikz,pgfplots} \pgfplotsset{ outer axis line style={line width=5pt,}, grid = major, tickwidth = 0, width=8cm, height=4cm, } \begin{document} \begin{tikzpicture} \begin{axis}[% xmin=-5, xmax=5, ymin=0, ymax=5, zmin=-5, zmax=0, view={20}{20}, ] \addplot3 {-sqrt(x^2 + y^2)}; \end{axis} \end{tikzpicture} \end{document} 

1 Answer 1

1

Pgfplots draws descriptions in some smart sequence which usually provides high quality.

In your case, you need set layers. The key set layers (or, equivalently, set layers=default) defines a specific layer sequence documented as follows:

A layer configuration which defines the layers axis background, axis grid, axis ticks, axis lines, axis tick labels, main, axis descriptions, axis foreground. They are drawn in the order of appearance. 

In particlar, it draws axis lines on top of axis grid which answers your question.

It looks like this:

\documentclass{standalone} \usepackage{tikz,pgfplots} \pgfplotsset{ outer axis line style={line width=5pt,}, grid = major, tickwidth = 0, width=8cm, height=4cm, set layers, } \begin{document} \begin{tikzpicture} \begin{axis}[% xmin=-5, xmax=5, ymin=0, ymax=5, zmin=-5, zmax=0, view={20}{20}, ] \addplot3[surf] {-sqrt(x^2 + y^2)}; \end{axis} \end{tikzpicture} \end{document} 

enter image description here

Further reading: pgfplots manual section 4.28 "Layers".

5
  • Thank you very much for solution! However I still wonder (after reading up on layers in the doc) why set layers=standard is not active, if there is no set layers keyword. Is it correct, that pgfplots automatically determines the layers, but fixes the given order (only) when encountering this key? Commented Dec 4, 2015 at 16:08
  • Yes, pgfplots still applies the heuristics which draws items in top of each other without activating set layers. Thus, it fixes the given order only when it encounters set layers. Maybe it will become the system default in some future version. Commented Dec 4, 2015 at 16:10
  • Furthermore the set layers key really messes up the groupplots, since obviously uses special layers. So the question how to apply this to 3D axes only remains! Or at least only to axes not using the groupplot environment. Commented Dec 4, 2015 at 16:12
  • 1
    There is an ugly defect in the software which messes up groupplots when used together with set layers. It exists up to and including version 1.12 (the latest stable at the time of this writing). In order to work around this limitation, you can use \pgfplotsset{set layers,cell picture=true}. I have finally managed to fixed that defect (thanks to god, was hard to catch). The fix will become part of 1.13. Commented Dec 4, 2015 at 16:15
  • Great work, Thank you very much for all your effort! Commented Dec 4, 2015 at 16:16

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.