# pgfplots: Grid Lines below Filling

I want to fill the area between two curves and have the grid lines below the filling. Is this possible?

(From Showing grid on top of plot fill with PGFplots? I thought axis on bottom might work, but this seems not to be a command.)

Edit: The filling method is the one suggested in Fill the area between two curves calculated by pgfplots by Christian Feuersanger, and requires a recent version of pgfplots.

\documentclass{standalone}
\usepackage{tikz,pgfplots}

\pgfplotsset{compat=1.10}
\usepgfplotslibrary{fillbetween}

\begin{document}

\begin{tikzpicture}
\begin{axis}[axis lines = middle,
smooth,
no markers,
xlabel = {$x$},
ylabel = {$y$},
minor tick num =1,
grid=both,
domain=0:2,]
\end{axis}
\end{tikzpicture}
\end{document}

-
@A.Ellett Do you have the newest version of pgfplots? I had to update it to use the filling method Christian Feuersanger recommended in tex.stackexchange.com/questions/17517/…. –  mrc Apr 11 at 15:44
@A.Ellett it works fine for me –  cmhughes Apr 11 at 16:01
@A.Ellett I follow the steps given in How do I update my TeX distribution? –  cmhughes Apr 11 at 16:08
@cmhughes It seems to be an issue with my current version of pgf. –  A.Ellett Apr 11 at 17:03

If you add set layers option the axis environment, it sets a hierarchricrhchaheal(!?) order as the standard layer order, namely axis background, axis grid, axis ticks, axis lines, axis tick labels, main, axis descriptions, axis foreground. This simply switches the order of drawing order. Hence it is feature not a bug. Otherwise you can reorder the layers as a customized layer style

\documentclass{standalone}
\usepackage{tikz,pgfplots}

\pgfplotsset{compat=1.10}
\usepgfplotslibrary{fillbetween}

\begin{document}

\begin{tikzpicture}
\begin{axis}[set layers,
axis lines = middle,
smooth,
no markers,
xlabel = {$x$},
ylabel = {$y$},
minor tick num =1,
grid=both,
domain=0:2,]
\end{axis}
\end{tikzpicture}
\end{document}

-