# Problem with snake ticks in pgfplots for bell shaped normal distribution

I want to draw two sided created region for normal distribution (see figure below). I have issue with snake ticks proper alignment and area looks suspicious to me. Am I missing something here? Any help will be highly appreciated. Thanks

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{arrows,backgrounds,snakes}
\begin{document}

\pgfmathdeclarefunction{gauss}{3}{%
\pgfmathparse{1/(#3*sqrt(2*pi))*exp(-((#1-#2)^2)/(2*#3^2))}%
}

\begin{tikzpicture}
\begin{axis}[
no markers
, domain=-3.2:3.2
, samples=100
, ymin=0
, axis lines*=left
, xlabel= $\textrm{X}$
, every axis y label/.style={at=(current axis.above origin),anchor=south}
, every axis x label/.style={at=(current axis.right of origin),anchor=west}
, height=5cm
, width=12cm
, xtick=\empty
, ytick=\empty
, enlargelimits=false
, clip=false
, axis on top
, grid = major
, hide y axis
]

\draw [help lines] (axis cs:-3.5, -0.4) grid (axis cs:3.5, 0.5);

\addplot [fill=cyan!20, draw=none, domain=-3:-1.96] {gauss(x, 0, 1)} \closedcycle;
\addplot [fill=cyan!20, draw=none, domain=1.96:3.2] {gauss(x, 0, 1)} \closedcycle;

\draw[snake=ticks, segment length=1cm] (axis cs:-3.1, 0) -- (axis cs:3.1, 0);

\node[below] at (axis cs:-2, -0.02)  {$\overline{\textrm{X}} - 2\textrm{S}$};
\node[below] at (axis cs:-1, -0.02)  {$\overline{\textrm{X}} - \textrm{S}$};
\node[below] at (axis cs:0, -0.02)  {$\overline{\textrm{X}}$};
\node[below] at (axis cs:1, -0.02)  {$\overline{\textrm{X}} + \textrm{S}$};
\node[below] at (axis cs:2, -0.02)  {$\overline{\textrm{X}} + 2\textrm{S}$};

\draw (axis cs:-3.2, -0.15) --(axis cs:3.2, -0.15) ;
\node[right] at (axis cs:3.2, -0.15) {$\textrm{Z}$};
\draw[snake=ticks, segment length=1cm] (axis cs:-3.1, -0.15) -- (axis cs:3.1, -0.15);

\node[below] at (axis cs:-2, -0.16)  {$-2$};
\node[below] at (axis cs:-1, -0.16)  {$-1$};
\node[below] at (axis cs:0, -0.16)  {$0$};
\node[below] at (axis cs:1, -0.16)  {$1$};
\node[below] at (axis cs:2, -0.16)  {$2$};

\end{axis}

\end{tikzpicture}

\end{document}

-
Can you also explain what snake ticks are ? snake decoration is obsolete and needs to be used with decorations.pathmorphing if I'm understanding it correctly. – percusse Mar 11 '13 at 20:31
@percusse Maybe the ticks decoration of the decorations.pathmorphing library that probably was snake=ticks in older versions? – Qrrbrbirlbel Mar 12 '13 at 4:02

There might be other solutions to this problem. However, here is my brute force solution.

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\begin{document}

\pgfmathdeclarefunction{gauss}{3}{%
\pgfmathparse{1/(#3*sqrt(2*pi))*exp(-((#1-#2)^2)/(2*#3^2))}%
}

\begin{tikzpicture}
\begin{axis}[
no markers
, domain=-3.2:3.2
, samples=100
, ymin=0
, axis lines*=left
, xlabel=
, every axis y label/.style={at=(current axis.above origin),anchor=south}
, every axis x label/.style={at=(current axis.right of origin),anchor=west}
, height=5cm
, width=12cm
, xtick=\empty
, ytick=\empty
, enlargelimits=false
, clip=false
, axis on top
, grid = major
, hide y axis
]

%\draw [help lines] (axis cs:-3.5, -0.4) grid (axis cs:3.5, 0.5);

\pgfmathsetmacro\valueA{gauss(1, 0, 1)}
\pgfmathsetmacro\valueB{gauss(2, 0, 1)}

\node[right] at (axis cs:3.4, 0) {$\textrm{X}$};

\draw [dashed] (axis cs:1, 0) -- (axis cs:1, \valueA)
(axis cs:-1, 0) -- (axis cs:-1, \valueA);

\draw [dashed] (axis cs:2, 0) -- (axis cs:2, \valueB)
(axis cs:-2, 0) -- (axis cs:-2, \valueB);

\draw [latex-latex](axis cs:-1, 0.15) -- node [fill=white] {\footnotesize $68.27\%$} (axis cs:1, 0.15);
\draw [latex-latex](axis cs:-2, 0.03) -- node [fill=white] {\footnotesize $95.45\%$} (axis cs:2, 0.03);

\node[below] at (axis cs:-3, -0.02)  {$\overline{\textrm{X}} - 3\textrm{S}$};
\node[below] at (axis cs:-2, -0.02)  {$\overline{\textrm{X}} - 2\textrm{S}$};
\node[below] at (axis cs:-1, -0.02)  {$\overline{\textrm{X}} - \textrm{S}$};
\node[below] at (axis cs:0, -0.02)  {$\overline{\textrm{X}}$};
\node[below] at (axis cs:1, -0.02)  {$\overline{\textrm{X}} + \textrm{S}$};
\node[below] at (axis cs:2, -0.02)  {$\overline{\textrm{X}} + 2\textrm{S}$};
\node[below] at (axis cs:3, -0.02)  {$\overline{\textrm{X}} + 3\textrm{S}$};

\draw (axis cs:-3.2, -0.15) --(axis cs:3.2, -0.15) ;
\node[right] at (axis cs:3.4, -0.15) {$\textrm{Z}$};

\draw[thick] (axis cs:-3.0, -0.01) -- (axis cs:-3.0, 0.01);
\draw[thick] (axis cs:-2.0, -0.01) -- (axis cs:-2.0, 0.01);
\draw[thick] (axis cs:-1.0, -0.01) -- (axis cs:-1.0, 0.01);
\draw[thick] (axis cs:-0.0, -0.01) -- (axis cs:0.0, 0.01);
\draw[thick] (axis cs:1.0, -0.01) -- (axis cs:1.0, 0.01);
\draw[thick] (axis cs:2.0, -0.01) -- (axis cs:2.0, 0.01);
\draw[thick] (axis cs:3.0, -0.01) -- (axis cs:3.0, 0.01);

\node[below] at (axis cs:-2, -0.16)  {$-2$};
\node[below] at (axis cs:-3, -0.16)  {$-3$};
\node[below] at (axis cs:-1, -0.16)  {$-1$};
\node[below] at (axis cs:0, -0.16)  {$0$};
\node[below] at (axis cs:1, -0.16)  {$1$};
\node[below] at (axis cs:2, -0.16)  {$2$};
\node[below] at (axis cs:3, -0.16)  {$3$};

\draw[thick] (axis cs:-3.0, -0.16) -- (axis cs:-3.0, -0.14);
\draw[thick] (axis cs:-2.0, -0.16) -- (axis cs:-2.0, -0.14);
\draw[thick] (axis cs:-1.0, -0.16) -- (axis cs:-1.0, -0.14);
\draw[thick] (axis cs:-0.0, -0.16) -- (axis cs:0.0, -0.14);
\draw[thick] (axis cs:1.0, -0.16) -- (axis cs:1.0, -0.14);
\draw[thick] (axis cs:2.0, -0.16) -- (axis cs:2.0, -0.14);
\draw[thick] (axis cs:3.0, -0.16) -- (axis cs:3.0, -0.14);

\end{axis}

\end{tikzpicture}

\end{document}


-