I'm trying to achieve a fade-out effect of my plot curve to the sides without affecting the grid. However, as I'm using path fading with white, the grid is also affected. Ideally this would be done by a separate command that I can just add after the plot like in my example, but any way to achieve the desired effect would be appreciated. A simple solution would be the use of axis on top with the fading inside the axis environment but I'd like to have the lines behind the fading plot.
\documentclass{standalone}
\usepackage{tikz,pgfplots}
\usetikzlibrary{fadings}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}[thick,smooth,no markers,grid=both,axis x line=bottom,axis y line = left,]
\addplot+[name path=A,blue!50] {sqrt(x)};
\addplot+[name path=B,blue!50] {sqrt(x/2)};
\addplot[blue!50,opacity=0.5] fill between[of=A and B];
\end{axis}
% fading
\fill [path fading=south,white]([yshift=0.1cm]current axis.north west) rectangle ([yshift=-0.5cm]current axis.north east);
\fill [path fading=west,white] ([xshift=-1.5cm]current axis.south east) rectangle ([xshift=0.1cm]current axis.north east);
% secondary axis so the x and y lines aren't faded (ideally not required)
\begin{axis}[%
grid=none,
axis x line=bottom,
axis y line = left,
minor tick num=0,
xlabel=,
ylabel=,
grid=none,
ticks=none]%in m
\end{axis}
\end{tikzpicture}
\end{document}
Thank you for any help!


