I am using ticklabel style={fill=white}
with pgfplots
to ensure my tick labels are readable despite my grid-lines. However, it seems that when I use fillbetween
the ticklabel
s get drawn after the fill and therefore show up on top of my diagram. If I use a \draw
command to draw a rectangle, the rectangle ends up on top of the ticklabel
, which is what I want.
Below is the code I am using and a figure
\begin{tikzpicture}
\begin{axis}[
xmin=-2,xmax=2,
ymin=-1,ymax=2,
x=1cm,y=1cm,
axis lines=middle,
grid=both,
minor tick num=0,
enlargelimits={abs=0.5},
ticklabel style={font=\tiny,fill=white},
]
\addplot[name path=f,no marks,mypink,thick,domain=-2:2, samples=25, draw=none] ({x},{x*x});
\addplot[no marks,thick,domain=-2:2, samples=25,smooth] ({x},{x*x});
\addplot[name path=g, no marks,thick,domain=-5:5, samples=2] ({x},{1.5});
\addplot [thick, color=blue, fill=blue, fill opacity=0.5] fill between [of=f and g, split];
\draw[fill=blue,opacity=0.5] (-1.5,-.5) rectangle(-.5,.5);
\end{axis}
\end{tikzpicture}