I'm trying to produce this:
But I can't get any further than this:
This is my code:
\documentclass{minimal}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{intersections}
\pgfmathdeclarefunction{normal}{2}{%
\pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
}
\makeatletter
\pgfmathdeclarefunction{erf}{1}{%
\begingroup
\pgfmathparse{#1 > 0 ? 1 : -1}%
\edef\sign{\pgfmathresult}%
\pgfmathparse{abs(#1)}%
\edef\x{\pgfmathresult}%
\pgfmathparse{1/(1+0.3275911*\x)}%
\edef\t{\pgfmathresult}%
\pgfmathparse{%
1 - (((((1.061405429*\t -1.453152027)*\t) + 1.421413741)*\t
-0.284496736)*\t + 0.254829592)*\t*exp(-(\x*\x))}%
\edef\y{\pgfmathresult}%
\pgfmathparse{(\sign)*\y}%
\pgfmath@smuggleone\pgfmathresult%
\endgroup
}
\makeatother
\pgfmathdeclarefunction{skew}{3}{%
\pgfmathparse{(exp(-((x-#1)^2)/(2*(#2)^2))*((erf((#3*(x-#1))/(sqrt(2)*#2)))+1))/(sqrt(2*pi)*#2)}%
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
hide y axis,
axis lines*=center,
axis on top,
no markers,
domain=-1:24,
samples=100,
xlabel=\empty,
ylabel=\empty,
every axis x label/.style={at=(current axis.right of origin),anchor=west},
every axis y label/.style={at=(current axis.above origin),anchor=south},
height=5cm, width=12cm,
xmin = -1, xmax=24,
xtick=, ytick=\empty,
enlargelimits=false,
clip=false
]
\addplot [name path=normal,very thick,cyan!85!black!50] {normal(14,3.416969)};
\addplot [name path=skew,very thick,red!85!black!50] {skew(1,4,10)};
\addplot [draw=green!70!black!20,very thick,fill=green!15!white!15,domain=-2:24] {min(normal(14,3.41696),skew(1,4,10))} \closedcycle;
\draw [red, thick, name intersections={of={normal and skew}}] ({rel axis cs:0,0}-|intersection-1) -- ({rel axis cs:0,1}-|intersection-1);
\end{axis}
\end{tikzpicture}
\end{document}
I have checked Fill the area determined by two pgfplots graphs, but this example just uses a preset number for the domain of the area to be filled, while I intend to use the intersection (which I can't fill in under domain
, e.g. domain:intersection-1:12
doesn't work so well).