Tikz verändern von Thema ist als GELÖST markiert

Tabellen und Grafiken erstellen und anordnen


MarkAnthony

Tikz verändern von

Beitrag von MarkAnthony »

Moin moin,
ich schreibe gerade an meiner Abschlussarbeit und arbeite mich gerade in Latex und auch Tikz ein. Bisher hat alles gut geklappt. Nur bin ich gerade an diesem Tikz Plot am verzweifeln. Je nach dem wie ich die samplerate anpasse verschiebt sich das Bild.
Wenn ich auch noch einen 2.ten Plot drüber lege verschiebt sich das Bild noch weiter. Vielen Dank euch schon mal für die Hilfe...
\documentclass[draft=false,paper=a4,twoside=false,fontsize=11pt,headsepline,BCOR10mm,DIV11]{scrbook}
\usepackage[ngerman,english]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{booktabs,array,subfigure,wrapfig,graphicx,tikz,pgfplots}
\usepackage{libertine,pifont,microtype,textcomp,setspace,makeidx,listings,mdwlist}
\usepackage[german,refpage]{nomencl}
\usepackage[style=numeric,backend=biber,maxcitenames=2,natbib=true
\usepackage[ngerman,colorlinks=true,colorlinks=true, breaklinks=true, citecolor=black, linkcolor=black, menucolor=black, urlcolor=black]{hyperref}
\usepackage{soul}
\usepackage[babel,german=guillemets]{csquotes}
\usepackage[europeanresistors]{circuitikz}
\usetikzlibrary{petri,plotmarks}

\begin{document}


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

\begin{figure}%\centering
\begin{tikzpicture}
\begin{axis}[
no markers,
domain=0:6,
samples=18,
axis lines=left,
xlabel=$x$,ylabel=$y$,
xmax=6.4,
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=5cm,width=12cm,xtick=\empty,ytick=\empty,
enlargelimits=false,
clip=false,
axis on top,
grid = major
]
\addplot [smooth,very thick,cyan!50!black,samples=14] {normal(x,3,1)};
\pgfmathsetmacro\valueA{normal(2,3,1)}
\pgfmathsetmacro\valueB{normal(3,3,1)}
\draw [gray] 	(axis cs:2,0.005) -- (axis cs:2,\valueA) 
				(axis cs:4,0.005) -- (axis cs:4,\valueA) 
				(axis cs:3,0.005) -- (axis cs:3,\valueB);
\draw [yshift=1.4cm, latex-latex](axis cs:2,0) -- node [fill=white] {$0.683$} (axis cs:4,0);
\node[below] at (axis cs:2,0)  {$\mu - \sigma$}; 
\node[below] at (axis cs:3,0)  {$\mu$}; 
\node[below] at (axis cs:4,0)  {$\mu + \sigma$};
\end{axis}
\end{tikzpicture}
\caption[Dichtefunktion der Gaußschen Normalverteilung]{Dichtefunktion der Gaußschen Normalverteilung mit dem Mittelwert $\mu$ und der Standardabweichung $\sigma$}
\end{figure}

\end{document}

Gast

Beitrag von Gast »

Das Beispiel ist leider nicht lauffähig: Argument of \@fileswith@ptions has an extra }.. Bitte melde dich an, damit du im Falle weiterer derartiger Fehler, deine Beiträge korrigieren kannst. Beachte unbedingt auch, dass du laut Minimalbeispiel-Anleitung nur Beispiele angeben sollst, die du abschließend (in einem neuen Verzeichnis) getestet hast.

nixversteh
Forum-Meister
Forum-Meister
Beiträge: 530
Registriert: Di 10. Aug 2010, 09:47
Wohnort: Wrestedt

...

Beitrag von nixversteh »

Hallo MarkAnthony85,

du musst diesen Code korrekt einfügen:
\usepackage[style=numeric,backend=biber,maxcitenames=2,natbib=true]{biblatex}
... mehr habe ich NICHT getestet.
Gruß
Martin
Zuletzt geändert von nixversteh am Fr 3. Feb 2017, 10:51, insgesamt 2-mal geändert.
Absence of evidence is not evidence of absence

MarkAnthony85
Forum-Newbie
Forum-Newbie
Beiträge: 4
Registriert: Fr 3. Feb 2017, 09:55
Wohnort: Hamburg

Beitrag von MarkAnthony85 »

Hab mich nun angemeldet. Entschuldigt bitte für das erste nicht lauffähige Bsp. Diesmal wurde der code von mir getestet. Bitte mal den Wert bei sample verändern zB auf sample=100 und dann auf sample=10. Dann seht Ihr was ich meine.
\documentclass[draft=false,paper=a4,twoside=false,fontsize=11pt,headsepline,BCOR10mm,DIV11]{scrbook}
\usepackage[ngerman,english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.14}
\usepackage[german,refpage]{nomencl}
\begin{document}
\pgfmathdeclarefunction{normal}{3}{%
\pgfmathparse{1/(#3*sqrt(2*pi))*exp(-((#1-#2)^2)/(2*#3^2))} }

\begin{figure}%\centering
\begin{tikzpicture}
\begin{axis}[
no markers,
domain=0:6,
samples=100,
axis lines=left,
xlabel=$x$,ylabel=$y$,
xmax=6.4,
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=5cm,width=12cm,xtick=\empty,ytick=\empty,
enlargelimits=false,
clip=false,
axis on top,
grid = major
]
\addplot [smooth,very thick,cyan!50!black] {normal(x,3,1)};
\pgfmathsetmacro\valueA{normal(2,3,1)}
\pgfmathsetmacro\valueB{normal(3,3,1)}
\draw [gray]    (axis cs:2,0.005) -- (axis cs:2,\valueA) 
            (axis cs:4,0.005) -- (axis cs:4,\valueA) 
            (axis cs:3,0.005) -- (axis cs:3,\valueB);
\draw [yshift=1.4cm, latex-latex](axis cs:2,0) -- node [fill=white] {$0.683$} (axis cs:4,0);
\node[below] at (axis cs:2,0)  {$\mu - \sigma$}; 
\node[below] at (axis cs:3,0)  {$\mu$}; 
\node[below] at (axis cs:4,0)  {$\mu + \sigma$};
\end{axis}
\end{tikzpicture}
\caption[Dichtefunktion der Gaußschen Normalverteilung]{Dichtefunktion der Gaußschen Normalverteilung mit dem Mittelwert $\mu$ und der Standardabweichung $\sigma$}
\end{figure}

\end{document}

Gast

Beitrag von Gast »

Super Beispiel! Ich kann sehen, was du meinst. Leider habe ich auf Anhieb keine Lösung.

Benutzeravatar
u_fischer
Forum-Meister
Forum-Meister
Beiträge: 4268
Registriert: Do 22. Nov 2012, 11:09
Kontaktdaten:

Beitrag von u_fischer »

Du hast in deiner Funktionsdefinition ein Leerzeichen am Ende.

Vergleiche


\pgfmathdeclarefunction{normal}{3}{%
\pgfmathparse{1/(#3*sqrt(2*pi))*exp(-((#1-#2)^2)/(2*#3^2))}}
mit
\pgfmathdeclarefunction{normal}{3}{%
\pgfmathparse{1/(#3*sqrt(2*pi))*exp(-((#1-#2)^2)/(2*#3^2))} }



MarkAnthony85
Forum-Newbie
Forum-Newbie
Beiträge: 4
Registriert: Fr 3. Feb 2017, 09:55
Wohnort: Hamburg

Beitrag von MarkAnthony85 »

VIELEN DANK. Es läuft nun.
Da wäre ich niemals drauf gekommen.

Antworten