123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- \documentclass[varwidth=true, border=5pt]{article}
- \usepackage[active,tightpage]{preview}
- \usepackage[latin1]{inputenc}
- \usepackage{amsmath}
- \usepackage{pgfplots}
- \usepackage{tikz}
- \usetikzlibrary{arrows,positioning}
- \usepackage{helvet}
- \usepackage[eulergreek]{sansmath}
- \pgfmathdeclarefunction{gauss}{2}{%
- \pgfmathparse{1/(sqrt(2*pi*#2))*exp(-((x-#1)^2)/(2*#2))}%
- }
- % to be used: \gauss(x)(mean)(variance)
- \makeatletter \newcommand{\pgfplotsdrawaxis}{\pgfplots@draw@axis} \makeatother
- \pgfplotsset{
- tick label style = {font=\sansmath\sffamily},
- every axis label/.append style={font=\sffamily\footnotesize},
- }
- \pgfplotsset{axis line on top/.style={
- axis line style=transparent,
- ticklabel style=transparent,
- tick style=transparent,
- axis on top=false,
- after end axis/.append code={
- \pgfplotsset{axis line style=opaque,
- ticklabel style=opaque,
- tick style=opaque,
- grid=none}
- \pgfplotsdrawaxis}
- }
- }
- \newcommand{\meanI}{60}
- \newcommand{\meanII}{40}
- \newcommand{\varI}{800}
- \newcommand{\varII}{100}
- \newcommand{\labelheight}{0.03}
- \pgfmathsetmacro{\meanIheight}{1/(sqrt(2*pi*\varI))}%
- \pgfmathsetmacro{\meanIIheight}{1/(sqrt(2*pi*\varII))}%
- \pgfmathsetmacro{\plotheight}{max(\meanIheight, \meanIIheight, \labelheight+0.002)}%
- \begin{document}
- \begin{preview}
- \tikzstyle{plotA}=[ultra thick,red!90!black]
- \tikzstyle{plotB}=[ultra thick,cyan!50!black]
- \begin{tikzpicture}
- \begin{axis}[
- width=13.5cm,
- height=8.625cm,
- % Grid
- grid = major,
- grid style={thin, dashed},
- % size
- xmin= 0, % start the diagram at this x-coordinate
- xmax= 125, % end the diagram at this x-coordinate
- ymin= 0, % start the diagram at this y-coordinate
- ymax= \plotheight, % end the diagram at this y-coordinate
- % Legende
- legend style={
- font=\large\sansmath\sffamily,
- at={(0.5,-0.18)},
- anchor=north,
- legend cell align=left,
- legend columns=-1,
- column sep=0.5cm
- },
- % Ticks
- tick align=inside,
- minor tick style={thick},
- scaled y ticks = false,
- ytick=\empty,
- % Axis
- axis lines = middle,
- axis line style = very thick,
- axis line on top,
- axis line style = {very thick,shorten <=-0.5\pgflinewidth},
- xlabel=$x$,
- x label style={at={(axis description cs:0.52,0)},
- anchor=north,
- font=\boldmath\Large},
- ylabel=$f(x)$,
- y label style={at={(axis description cs:0,0.5)},
- anchor=south,
- rotate=90,
- font=\boldmath\Large},
- ]
- % Plots of the distributions
- \addplot [domain=0:120,samples=200,plotA] {gauss(\meanI,\varI)};
- \addplot [domain=0:120,samples=200,plotB] {gauss(\meanII,\varII)};
- % Add labels
- \node[plotA,above] at (axis cs:102,0.01){\Large $\mathcal{N}(\meanI,\varI)$};
- \node[plotB,above] at (axis cs:20,0.03){\Large $\mathcal{N}(\meanII,\varII)$};
- \end{axis}
- \end{tikzpicture}
- \end{preview}
- \end{document}
|