Is there an easy way to place the border box of a tikz graph on top, while keeping the grid lines behind data lines?
\begin{axis}[axis on top]
The above puts the border, x grid lines, and y grid lines. I just want the border on top, leaving the grids. The image below you'll see I have multiple fills which overlap the border, which looks bad. All I want to do is put the border on top so it covers the fills.
Thank you.
Best Answer
Package
pgfplots
supports layers. From its documentation I would have expected that eitheror
should have worked. But neither the axis lines could be moved to the foreground layer, neither the grid to the background layer. (Tested version of
pgfplots
is 2015/05/02 v1.12.1.)From experiments I concluded, that the axis lines are put on the
main
layer below the plots. Thus the following examples successfully moved the plots to thepre main
layer under themain
layer:Update for pgfplots 2020/02/29 v1.17
The previous example does not work with later versions of pgfplots. This is solved by defining a new layer configuration
axis lines on top
that moves theaxis lines
layer beforemain
.