# Add a gaussian curve in a specific location in a tikz diagram

I'd like to put a gaussian curve in a specific location in a diagram I am creating with tikz.

I found the question Bell Curve/Gaussian Function in TikZ/PGF, and I can use this to add the gaussian curve to my diagram, but I don't know how to put it in the proper place. The gaussian should be centered at (0,10) in the tikz diagram. Here is my code so far:

\documentclass[12pt]{article}

\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
\pagestyle{empty}

\begin{tikzpicture}

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

\pgfmathsetmacro{\phcy}{3.5}

% draw beam and dimension
\draw[line width=2] (0,\phcy) -- +(-3,10) ;
\draw[line width=2] (0,\phcy) -- +(3,10) ;
\draw[line width=1.5,<->] (0,\phcy) ++(73.6:10) arc (73.6:106.3:10);
\node at (0,\phcy+9.5) {$\Theta_{FWHM}$};

\begin{axis}[style={samples=200,smooth},
axis lines=none]
\end{axis}

\end{tikzpicture}

\end{document}

• You can add anchor=origin, at={(0,10cm)} to the axis options to position the plot. Do you also want the plot to have a specific width/height? – Jake Aug 15 '13 at 8:32
• Welcome to TeX.SX! – mafp Aug 15 '13 at 8:37
• Thank you Jake! Yes, I think I will want it to have a specific height/width. What makes the most sense to me is to set things so that a gauss(0,1) has a \sigma of 1 cm. I can't really tell by eye whether that's happening now. – Dan Becker Aug 15 '13 at 8:54

You can add anchor=origin, at={(0,10cm)} to the axis options to position the plot. To make the width of the plot correspond to the units of the drawing, you can also set x=1cm in the axis \documentclass[12pt]{article}

\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
\pagestyle{empty}

\begin{tikzpicture}

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

\pgfmathsetmacro{\phcy}{3.5}

% draw beam and dimension
\draw[line width=2] (0,\phcy) -- +(-3,10) ;
\draw[line width=2] (0,\phcy) -- +(3,10) ;
\draw[line width=1.5,<->] (0,\phcy) ++(73.6:10) arc (73.6:106.3:10);
\node at (0,\phcy+9.5) {$\Theta_{FWHM}$};

\begin{axis}[
anchor=origin,
x=1cm,
at={(0,10cm)},
style={samples=51,smooth},
hide axis
]

• For those curious, this usage of anchor and at is documented in section 4.18.1 of the PGFPLOTS manual (revision 1.8). The use of x to set a distance scale is covered in section 4.9. – Dan Becker Aug 15 '13 at 19:16