4

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.enter image description here

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 http://www.texample.net/tikz/ specialy examples/animated-distributions/ ... – Zarko Feb 09 '17 at 15:23

2 Answers2

6

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:

enter image description here

\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}
Sebastiano
  • 54,118
0

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.

TeXnician
  • 33,589