This is a follow up question to Jake's solution to that post.
Although I got Jake's solution there work in LaTeX document perfectly fine, I could not get it work in beamer. Here's Jake's code but using beamer:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usepackage{pgfplots}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\tikzset{
hatch distance/.store in=\hatchdistance,
hatch distance=10pt,
hatch thickness/.store in=\hatchthickness,
hatch thickness=2pt
}
\makeatletter
\pgfdeclarepatternformonly[\hatchdistance,\hatchthickness]{flexible hatch}
{\pgfqpoint{0pt}{0pt}}
{\pgfqpoint{\hatchdistance}{\hatchdistance}}
{\pgfpoint{\hatchdistance-1pt}{\hatchdistance-1pt}}%
{
\pgfsetcolor{\tikz@pattern@color}
\pgfsetlinewidth{\hatchthickness}
\pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
\pgfpathlineto{\pgfqpoint{\hatchdistance}{\hatchdistance}}
\pgfusepath{stroke}
}
\begin{axis}[
xmin=-4,xmax=4,
xlabel={z},
ymin=0,ymax=1,
axis on top,
legend style={legend cell align=right,legend plot pos=right}]
\addplot[color=red,domain=-4:4,samples=100] {1/sqrt(2*pi)*exp(-x^2/2)};
\addlegendentry{z}
\addplot+[mark=none,
domain=0:1,
samples=100,
pattern=flexible hatch,
area legend,
pattern color=red]{1/sqrt(2*pi)*exp(-x^2/2)} \closedcycle;
\addlegendentry{Interval 1}
\addplot+[mark=none,
domain=-2:-0.5,
samples=100,
pattern=flexible hatch,
hatch distance=5pt,
hatch thickness=0.5pt,
draw=blue,
pattern color=cyan,
area legend]{1/sqrt(2*pi)*exp(-x^2/2)} \closedcycle;
\addlegendentry{Interval 2}
\end{axis}
\end{tikzpicture}
\end{frame}
\end{document}
It seems the system never finish compiling. I not sure whether it is just my system or it is a more general problem?
Meanwhile, Marco's solution there does work in beamer.

\documentclassand the appropriate packages so that those trying to help don't have to recreate it. – Peter Grill Jul 25 '12 at 01:20