I have two Guassian distribution curves, as shown here and I am attempting to color the areas under the curves as well as the intersection between them, like here:
I assumed fillbetween
would be the appropriate tool here, but that produced some strange results. Below is the code
\begin{tikzpicture}
\begin{axis}[
axis lines=left,
domain=0:10,
samples=100,
ymin=0,
xtick=\empty,
ytick=\empty,
enlargelimits=false,
clip=false,
]
\addplot [thick, orange, name path=cat] {gauss(x, 3, 1)} node[pos=0.3, above]{cat};
\addplot [thick, purple!70!black, name path=puma] {gauss(x, 5, 0.5)} node[pos=0.5, above right] {puma};
\path[name path=axis] (axis cs:0,0) -- (axis cs:10,0);
\addplot[
thick,
color=orange,
fill=yellow,
fill opacity=0.25
]
fill between[
of=cat and axis
];
\addplot[
thick,
color=purple!70!black,
fill=purple!70!black,
fill opacity=0.25
]
fill between[
of=puma and axis
];
\addplot[
thick,
color=white,
fill=blue,
fill opacity=0.25
]
fill between[
of=cat and puma
];
\end{axis}
\end{tikzpicture}
which produces this:
Every other answer I've found either miraculously makes fillbetween
work or avoids it entirely (usually in ways that seem more complicated than is necessary for a simple task such as this).
Can anyone explain to me what is missing to make fillbetween
achieve the desired results or recommend a clean alternative? Thanks in advance.