2

I tried to follow Jake from Plotting bell shaped curve in TikZ-PGF with slight modification.

1) I just want the univariate normal cdf with red dash line at the cut-off, but some how my dash line seem awkward.

2) why the y axis label is in the middle of figure, not along with y-axis?

\documentclass{article}
\usepackage{pgfplots}
\begin{document}

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

    \begin{tikzpicture}
    \begin{axis}[
      no markers, domain=-4:4, samples=100,
      axis lines*=left, xlabel=$x$, ylabel=$y$,
      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=4cm, width=7cm,
      xtick={-3,-2,-1,0,1,2,3}, ytick=\empty,
      enlargelimits=false, clip=false, axis on top,
      grid = none
      ]
       \draw[dashed, red, thick] (axis description cs: 1.32,0) -- (axis description cs:1.32, 1);
      \addplot [fill=cyan!20, draw=none, domain=-4:1.32] {gauss(0,1)} \closedcycle;
      \addplot [very thick,cyan!50!black] {gauss(0,1)};
    \end{axis}

    \end{tikzpicture}
\end{document}

enter image description here

PenKoNN
  • 41
  • 1
  • your third axis options line every axis y label/.style={at=(current axis.above origin),anchor=south}, determines the y label position. If you comment it out, it gets better (but I do not know a good solution)
  • you need axis cs instead of axis description cs., and probably you should change the addplot order to plot the red dashed line as the last one.
  • – crateane Jun 09 '16 at 10:58
  • For the y label: every axis y label/.style={at=(current axis.north west),anchor=south}. I would suggest to use \pgfplotsset{compat=1.13}. Starting with version 1.11 it would be possible to use: \draw[dashed, red, thick] (1.32,0) -- (1.32, 1); – esdd Jun 09 '16 at 11:04
  • Thanks Faekynn & esdd. Your suggestions work. I really appreciate!! – PenKoNN Jun 11 '16 at 07:45
  • 4
    I'm voting to close this question as off-topic because it was solved in the comments – Stefan Pinnow Oct 10 '16 at 16:14