Basically I am going to use a lot of very similar plots, with a difference in the placement of 2 boundaries, and the position of 2 labels, so I would like to be able to just enter those 2 numbers as arguments, and let LaTeX take care of it. My failed attempt:
\documentclass{article}
\usepackage{pgfplots}
\usepackage{mathtools}
\usepackage{xparse}
\pgfmathdeclarefunction{gauss}{2}{%
\pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
}
%zc,zt
\NewDocumentCommand{\hypplot}{ m m }
{%
\begin{tikzpicture}
\begin{axis}[
no markers, domain=-4:4,
samples=100, axis lines*=left,
every axis x label/.style={at=(current axis.right of origin),anchor=west},
height=5cm, width=12cm,
ytick=\empty, xtick=\empty,
enlargelimits=false, clip=false, axis on top,
y axis line style={draw=none},
]
%%Shade the area for alpha
\addplot [fill=cyan!20, draw=none, domain=-4:#1] {gauss(0,1)} \closedcycle;
%%Shade the area for p-value
\addplot [fill=orange!20, draw=none, domain=#1:#2] {gauss(0,1)} \closedcycle;
%%draw the gaussian
\addplot [very thick,cyan!50!black] {gauss(0,1)};
%%draws a double-headed arrow for Zc
\draw [latex-latex] (axis cs:#1,-0.07) -- node [fill=white] {$\displaystyle \zcl{c}\frac{\sigma}{\sqrt{n}}$} (axis cs:0,0.-0.07);
%%draws a double-headed arrow for Zt
\draw [yshift=-0.6cm, latex-latex] (axis cs:#2,0.16) -- (axis cs:0,0.16);
%%Label Zt
\draw [yshift=-0.6cm](axis cs:(#1+#2)/2,0.22) node {$\displaystyle \zcl{T}\frac{\sigma}{\sqrt{n}}$};
%%label the mean
\draw (axis cs:0,.43) node {$\mu=\mu_0^{}$};
\addplot +[mark=none] coordinates {(0, 0) (0, 0.3989)};
%%add alpha
\draw (axis cs:#1*1.071,0.02) node {$\alpha$};
\addplot +[mark=none] coordinates {(#1, -.01) (#1, 0.08)};
\draw (axis cs:#1*1.02,0.10) node {$\bar{x}_c^{}$};
%add p-value border
\addplot +[mark=none] coordinates {(#2, -.01) (#2, 0.22)};
\draw (axis cs:#2*1.02,0.25) node {$\bar{x}$};
\end{axis}
\end{tikzpicture}%
}
\begin{document}
\hypplot{-1.96}{-1.08}
\end{document}
I suppose I can always just copy paste and change each of them, but wouldn't it be nice to have a command to do it?