PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : TikZ plot verschwindet bei weiteren Zeichenelementen



alexraasch
17-08-2009, 21:10
Hallo,

ich möchte die Dichtefunktion einer Normalverteilung mit TikZ plotten. Ich habe die (x,y)-Paare mit R berechnet und plotte aus einer externen Textdatei mit TikZ. Das funktioniert auch problemlos. Aber sobald ich in dem {tikzpicture} noch weitere Zeichenbefehle einfüge, verschwindet der Plot und es bleiben nur noch die anderen Elemente stehen.

Kann mir da jemand helfen?


Beispielcode:


\documentclass[10pt, a4paper]{report}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[width=19cm,height=25cm]{geometry}
\usepackage{comment}
\usepackage{tikz}
\usetikzlibrary{%
arrows,%
calc,%
fit,%
patterns,%
plotmarks,%
shapes.geometric,%
shapes.misc,%
shapes.symbols,%
shapes.arrows,%
shapes.callouts,%
shapes.multipart,%
shapes.gates.logic.US,%
shapes.gates.logic.IEC,%
er,%
automata,%
backgrounds,%
chains,%
topaths,%
trees,%
petri,%
mindmap,%
matrix,%
calendar,%
folding,%
fadings,%
through,%
positioning,%
scopes,%
decorations.fractals,%
decorations.shapes,%
decorations.text,%
decorations.pathmorphing,%
decorations.pathreplacing,%
decorations.footprints,%
decorations.markings,%
shadows}

\begin{document}
\begin{tikzpicture}
\draw[smooth] plot file {norm.txt};
% Funktioniert NICHT, wenn folgendes hinzukommt:
% \draw[->] (0,0) -- (1,1);
\end{tikzpicture}
\end{document}


Mein zweiter Versuch, indem die Funktionswerte direkt als Koordinaten eingegeben werden:



\documentclass[10pt, a4paper]{report}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[width=19cm,height=25cm]{geometry}
\usepackage{comment}
\usepackage{tikz}
\usetikzlibrary{%
arrows,%
calc,%
fit,%
patterns,%
plotmarks,%
shapes.geometric,%
shapes.misc,%
shapes.symbols,%
shapes.arrows,%
shapes.callouts,%
shapes.multipart,%
shapes.gates.logic.US,%
shapes.gates.logic.IEC,%
er,%
automata,%
backgrounds,%
chains,%
topaths,%
trees,%
petri,%
mindmap,%
matrix,%
calendar,%
folding,%
fadings,%
through,%
positioning,%
scopes,%
decorations.fractals,%
decorations.shapes,%
decorations.text,%
decorations.pathmorphing,%
decorations.pathreplacing,%
decorations.footprints,%
decorations.markings,%
shadows}

\begin{document}
\begin{tikzpicture}
\draw[smooth] plot coordinates {
(95,0.0000000472766)
(95.02506,0.0000000541666)
(95.05013,0.0000000620244)
(95.07519,0.0000000709808)
(95.10025,0.000000081183)
(95.12531,0.0000000927973)
(95.15038,0.0000001060113)
(95.17544,0.0000001210362)
(95.2005,0.0000001381098)
% ... noch 300 Werte ...
};
\end{tikzpicture}
\end{document}

bobmalaria
17-08-2009, 22:12
hi,

alternativer (funktionierender) vorschlag


\documentclass{scrreprt}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
\begin{axis}[
xlabel=xlabel,
ylabel={ylabel},
%xmin=0,
%ymax=3e-3,
mark options={scale=0.3},
legend style={legend columns=1,at={(1.3,1)}}
]
\addplot plot file {norm.txt};
\addlegendentry{irgendwas};
\node[coordinate,pin=right:{Start}]
at (axis cs:95,0.1) {};
\node[coordinate,pin=left:{Ende}]
at (axis cs:105,0.1) {};
\end{axis}
\draw[->] (0,0) -- (1,1);
\end{tikzpicture}
\end{document}

alexraasch
18-08-2009, 11:47
Danke für die Lösung. Kann man denn da auch ein Grid hineinzeichnen?

bobmalaria
18-08-2009, 12:43
hi,

ich denke schon. im prinzip funktioniert alles was in tikz auch geht. in wissenschaftlichen arbeiten finde ich aber ein grid eher selten...

wenn du einzelne punkte markieren willst gibt es dafür sehr nette optionen. in der doku ist alles beschrieben. schau einfach mal rein.

ein grid kann man, denke ich, innerhalb der axis-umgebung mit einer schleife a la: for \y 1..5 \draw (0,\y) -- (5,\y) mal so als pseudocode.

aber überlege dir das nochmal gut. eventuell gibt es auch eine option dafür oder die tikz-grid befehle funktionieren. versucht abe ich es nicht

alexraasch
19-08-2009, 00:37
OK, werde es mal ausprobieren und mir die Anleitung zu Gemüte führen. Das Grid ist mehr als Zeichenhilfe gedacht -- ich will das ganze ausdrucken und dann ein paar Kollegen daran etwas über statistische Prozesskontrolle erklären.

bobmalaria
19-08-2009, 08:49
hi,

innerhalb der aches, zählt das koordinatensystem deiner werte. also wenn du eine x-achse von 0...5 und eine y-achse von 0...0.5 hast, dann kannst du direkt diese koordinaten verwenden um dinge einzuzeichnen.

gruss