I'm trying to shade the domain bounded by the parabolas y=-x^2, y=x^2+1, and the lines x=-1, x=3.
By using the answer of @Salim Bou here pgfplots fillbetween with multiple curves, I've used the following code:
\begin{figure}[h]
\begin{tikzpicture}
\begin{axis}
[xlabel=$x$,ylabel=$y$,axis lines=middle,xtick={30},ytick={30},no marks,axis equal,xmin=-2,xmax=4,ymin=-10,ymax=10,enlargelimits={upper=0.1}]
\addplot[no markers,thick,samples=1001, samples y=0,domain=-1:3,variable=x, name path=A]({ x },{ -x^2 });
\addplot[no markers,thick,samples=1001, samples y=0,domain=-1:3,variable=x, name path=B]({ x },{ x^2+1 });
\addplot[no markers,thick,samples=3, samples y=0,domain=-1:2,variable=t]({ -1 },{ t });
\addplot[no markers,thick,samples=3, samples y=0,domain=-9:10,variable=t]({ 3 },{ t });
\addplot[gray!30,opacity=0.6] fill between[of=A and B, soft clip={domain=-1:3}];
\node[above right] at (0,0) {\scalebox{0.5}{$O$}};
\node[below left] at (-1,0) {\scalebox{0.5}{$-1$}};
\node[below right] at (3,0) {\scalebox{0.5}{$3$}};
\end{axis}
\end{tikzpicture}
\end{figure}
But it seems that the command \addplot[gray!30,opacity=0.6] fill between[of=A and B, soft clip={domain=-1:3}] doesn't have any effect at my example.
How can I fix this ?



samples=1001form the definiton of A and B, it works. Seems that the limit is between 100 and 200; when it fails, it says:Package pgf Warning: fill between skipped: the first input path is empty. on in put line 28.– Rmano Dec 22 '17 at 14:37soft clipit works, whichever the number of samples. Puzzling... – Rmano Dec 22 '17 at 14:40