Closed joelkim closed 4 years ago
Hi, I added a --pgfplotslibrary option to use fillbetween pgfplotslibrary.
--pgfplotslibrary
fillbetween
The code:
%%tikz -p pgfplots -g fillbetween \pgfmathdeclarefunction{gauss}{2}{% \pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}% } \pgfplotsset{compat=1.10} \begin{axis}[ domain=0:10, samples=100, enlargelimits=false, ] \addplot [very thick, red!50!black, name path=f] {gauss(5,1)}; \addplot [name path=axis] coordinates {(0,0)(10,0)}; \addplot [thick,fill=green,fill opacity=0.4] fill between[of=f and axis,soft clip={domain=0:3.5}]; \addplot [thick,fill=red,fill opacity=0.4] fill between[of=f and axis,soft clip={domain=3.5:6.5}]; \addplot [thick,fill=green,fill opacity=0.4] fill between[of=f and axis,soft clip={domain=6.5:10}]; \end{axis}
generates the following figure.
Hi, I added a
--pgfplotslibrary
option to usefillbetween
pgfplotslibrary.The code:
generates the following figure.