# Drawing a Normal Distribution Graph [duplicate]

I have no idea how to create a graph of a normal distribution. I'll attach an image of exactly what I'm trying to recreate.

Also, is there a way of undoing a PDF back to LaTeX code if LaTeX was used to make the pdf? otherwise I'll just be mindlessly copying...

• Welcome to TeX.SE. Gauus function (normal distribution) has been asked and answered many time here. Joust search the list, than look to texample.net/tikz specialy examples/animated-distributions/ ... – Zarko Feb 9 '17 at 15:23

You could see this link Filling in the area under a normal distribution curve or you could use this next example adapted from this link http://johncanning.net/wp/?p=1202:

\documentclass{article}
\usepackage{pgfplots}
\usepackage{mathtools,amssymb}
\usepackage{tikz}
\usepackage{xcolor}
\pgfplotsset{compat=1.7}
\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=0:10, samples=100,
axis lines*=left, xlabel=Test, ylabel=axis $y$,
height=6cm, width=10cm,
xticklabels={Test A,Test B,Test C,Test D, Test A,Test B,Test C,Test D}, ytick=\empty,
enlargelimits=false, clip=false, axis on top,
grid = major]
\addplot [fill=cyan!20, draw=none, domain=-3:3] {gauss(0,1)} \closedcycle;
\addplot [fill=orange!20, draw=none, domain=-3:-2] {gauss(0,1)} \closedcycle;
\addplot [fill=orange!20, draw=none, domain=2:3] {gauss(0,1)} \closedcycle;
\addplot [fill=blue!20, draw=none, domain=-2:-1] {gauss(0,1)} \closedcycle;
\addplot [fill=blue!20, draw=none, domain=1:2] {gauss(0,1)} \closedcycle;
\end{axis}
\end{tikzpicture}
\end{document}

• Looks like the above code may have been taken from this page johncanning.net/wp/?p=1202 which has more for display. – Relative0 Mar 6 '20 at 4:24
• @Relative0 Thank you very much. Now edit my answer. – Sebastiano Mar 6 '20 at 12:59

Okay, plotting Gauss is not that hard, you could e.g. adapt the solution from here. Basically it defines a math function gauss for pgfplots and then uses it. It's pretty straightforward.

Regarding the transition PDF to LaTeX there is unfortunately no easy way. You can of course include the PDF as figure, but you won't get back TikZ code for instance.