I'm trying to fill the area between two curves. Ideally, what I want to do is already answered here, but I get the following warning (twice):
Package pgf Warning: fill between skipped: the first input path is empty. on input line 48.
And this is what I have tried so far
\documentclass{article}
\usepackage{tikz,graphicx}
\usepackage{pgfplots, pgfplotstable}
\usepgfplotslibrary{statistics}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns,intersections}
\pgfplotsset{compat=newest}
\usetikzlibrary{babel}
\begin{document}
\begin{figure}%[ht]
\centering
\begin{tikzpicture}
\begin{axis}[
xmin=-2,xmax=7,
ymin=0,ymax=1.5,
axis x line=middle,
axis y line=middle,
axis line style=-,
xlabel={$x$},
ylabel={$y$},
]
% parte negra de f1
\addplot[no marks,black,-] expression[domain=-2:3,samples=100]{exp(-0.5*(x-2)^2)}
node[pos=-0.5,anchor=north east]{};
% parte negra de f2
\addplot[no marks,black,-] expression[domain=3:7,samples=100]{exp(-0.5*(x-4)^2)}
node[pos=-0.5,anchor=north east]{};
% parte azul de f1
\addplot+[no marks,blue,thick,-] [name path=f1,domain=3:7,samples=1000]{exp(-0.5*(x-2)^2)}
node[pos=0,anchor=north east]{};
% parte azul de f2
\addplot[no marks,blue,thick,-] expression[name path=f2,domain=-2:3,samples=1000]{exp(-0.5*(x-4)^2)}
node[pos=0,anchor=north east]{};
\draw (2,1) ++(90:0.2cm) ++(90:0.25cm) node [fill=none](fk1){$f_1(x)$};
\draw (4,1) ++(90:0.2cm) ++(90:0.25cm) node [fill=none](fk2){$f_2(x)$};
% eje x
\addplot[name path=xAxis,const plot,thick,no marks,draw=none] coordinates {(0,0) (1,0)};
\addplot[blue!20!white] fill between[of=f1 and xAxis,soft clip={domain=3:7}];
\addplot[blue!20!white] fill between[of=f2 and xAxis,soft clip={domain=-2:3}];
\end{axis}
\end{tikzpicture}
\caption{Función logística o sigmoidal}
\label{fig:Two plots}
\end{figure}
\end{document}
which should render to
with the area under the blue segments filled. As a bonus, I'd like the x label not to collide with the curve. Any ideas where to add `name path global=axis?



\drawcall? (we can take this conversation to chat) – mrbolichi Mar 30 '17 at 09:44declare function,xticklabel csandintersection segmentsyou will find the answers in the manuals of TikZ and PGFPlots. Regarding thecompatlevel, please have a look at the comment in the code. To make the code as is it is required to use thiscompatlevel or higher. What thecompatlevel is good for/does do, please also have a look at the PGFPlots manual section 2.2.1. – Stefan Pinnow Mar 30 '17 at 13:54