# [Tex/LaTex] PGFPLOTS 3d box line for Z axis not being drawn

3dpgfplotstikz-pgf

The vertical 3d box line for Z axis is not being drawn. If I make the grid lines dashed, the line is drawn, but also appears dashed, as the grid lines.

To me, it looks that the line is in fact drawn, but it seems to be behind the grid (that's why it would appear dashed with the dashed grid).

UPDATE: Just confirmed, if I remove grids with grids = none the box line appears.

Any way to fix this?

MWE (for dashed, just uncomment the grid style line):

\documentclass[12pt,a4paper]{report}
\usepackage[latin1]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.3}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
width=8cm,
height=8cm,
grid = major,
%grid style={dashed, gray!50},
scale only axis,
xmin=-2, xmax=2,
xtick={-2,-1,0,1,2},
xlabel={X},
ymin=-2, ymax=2,
ytick={-2,-1,0,1,2},
ylabel={Y},
zmin=0, zmax=4,
ztick={0,1,2,3,4},
zlabel={Z},
3d box=background,
view={322.5}{30},]

color=black,
mark size=2.5pt,
only marks,
mark=*,
mark options={solid}]
table {
-0.25 -0.25 3
};
color=black,
mark size=2.5pt,
only marks,
mark=*,
mark options={solid}]
table {
-0.25 0.25 3
};
color=black,
mark size=2.5pt,
only marks,
mark=*,
mark options={solid}]
table {
0.25 0.25 3
};
color=black,
mark size=2.5pt,
only marks,
mark=*,
mark options={solid}]
table {
0.25 -0.25 3
};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}


Results:

You can solve the issue by added set layers to your axis. This activates layered graphics for your tikzpicture, and the layers are drawn in the correct sequence. The default is to the single axes individually, which can cause the observed effect. Setting set layers should not have any negative effect on the appearance and the small additional runtime cost is probably irrelevant.
The feature set layers is relatively new and requires pgfplots 1.7