von ghostify24 » Di 13. Jun 2017, 12:57
Hi, Forum Gemeinde, hätte da ein kleines Problem mit der Erstellung eines Grafen mit Tikzpictures. Bis vor kurzem hat es auch funktioniert leider heute morgen nicht mehr, hmmm. Bin leider auch etwas im Stress, Thesis muss langsam zum Ende kommen. Vielleicht sieht ja jemand den Fehler, der sich im Eifer des Gefechtes eingeschlichen hat.
Danke schon mal.
\documentclass{article}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.14}
% Gauss function, parameters mu and sigma
% #1 is \mu; #2 is \sigma
\pgfmathdeclarefunction{gaussian}{2}{ %exp(\frac{(x-\mu)^2}{2*\sigma^2})
\pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}} %\sigma*\sqrt{2*pi}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[no markers, domain=97.8:102.2, samples=250, axis lines=left, xlabel=$x$, ylabel=$f_{X}(x)$,
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=6cm, width=12cm, ymin=0, ymax=1.5,
ticks=none, %Ausblenden der Achsenskalierung, auskommentieren falls Skalen erwünscht
ytick={0.25,0.50,0.75,0.90,1},
xtick={97,97.5,98,98.5,99,99.5,100,100.5,101,101.5,102,102.5,103,103.5},
enlargelimits=false, clip=false, axis on top]
\addplot [very thick,cyan!50!black] {gaussian(100,0.8}; % #1 is \mu; #2 is \sigma^2
\addplot [very thick,cyan!50!black] {gaussian(100,0.5)};
\addplot [very thick,cyan!50!black] {gaussian(100,0.3)};
%\draw (axis cs: 100,-.1) node [fill=none] {$\mu$};
\draw [<-](axis cs: 100.30,1.1) -- (axis cs: 100.60,1.4) node [fill=white] {$\sigma_1$};
\draw [<-](axis cs: 100.65,0.5) -- (axis cs: 101.05,0.9) node [fill=white] {$\sigma_2$};
\draw [<-](axis cs: 101.25,0.2) -- (axis cs: 101.65,0.6) node [fill=white] {$\sigma_3$};
\draw (axis cs: 101.5,1.45) node [fill=none] {$\sigma_1<\,\sigma_2<\,\sigma_3$};
\draw [dotted](axis cs: 100,0) -- (axis cs: 100,1.3);
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
Hi, Forum Gemeinde, hätte da ein kleines Problem mit der Erstellung eines Grafen mit Tikzpictures. Bis vor kurzem hat es auch funktioniert leider heute morgen nicht mehr, hmmm. Bin leider auch etwas im Stress, Thesis muss langsam zum Ende kommen. Vielleicht sieht ja jemand den Fehler, der sich im Eifer des Gefechtes eingeschlichen hat.
Danke schon mal. :D
[code]
\documentclass{article}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.14}
% Gauss function, parameters mu and sigma
% #1 is \mu; #2 is \sigma
\pgfmathdeclarefunction{gaussian}{2}{ %exp(\frac{(x-\mu)^2}{2*\sigma^2})
\pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}} %\sigma*\sqrt{2*pi}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[no markers, domain=97.8:102.2, samples=250, axis lines=left, xlabel=$x$, ylabel=$f_{X}(x)$,
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=6cm, width=12cm, ymin=0, ymax=1.5,
ticks=none, %Ausblenden der Achsenskalierung, auskommentieren falls Skalen erwünscht
ytick={0.25,0.50,0.75,0.90,1},
xtick={97,97.5,98,98.5,99,99.5,100,100.5,101,101.5,102,102.5,103,103.5},
enlargelimits=false, clip=false, axis on top]
\addplot [very thick,cyan!50!black] {gaussian(100,0.8}; % #1 is \mu; #2 is \sigma^2
\addplot [very thick,cyan!50!black] {gaussian(100,0.5)};
\addplot [very thick,cyan!50!black] {gaussian(100,0.3)};
%\draw (axis cs: 100,-.1) node [fill=none] {$\mu$};
\draw [<-](axis cs: 100.30,1.1) -- (axis cs: 100.60,1.4) node [fill=white] {$\sigma_1$};
\draw [<-](axis cs: 100.65,0.5) -- (axis cs: 101.05,0.9) node [fill=white] {$\sigma_2$};
\draw [<-](axis cs: 101.25,0.2) -- (axis cs: 101.65,0.6) node [fill=white] {$\sigma_3$};
\draw (axis cs: 101.5,1.45) node [fill=none] {$\sigma_1<\,\sigma_2<\,\sigma_3$};
\draw [dotted](axis cs: 100,0) -- (axis cs: 100,1.3);
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}[/code]