Der folgende Graph zeigt ein einfaches Baumdiagramm, für die Wahrscheinlichkeiten beim Münzwurf.
Häufige auftretenden Styles wurden dabei allgemein definiert. Der Knackpunkt war hier ein wenig die Färbung der Wurzel, des ‘circle split’ mit der background-Bibliothek.
<pre>\documentclass[varwidth, margin=5pt]{standalone}
\usepackage[ngerman]{babel}
\usepackage{selinput}
\SelectInputMappings{adieresis={ä}, germandbls={ß}}
\usepackage{tikz}
\usetikzlibrary{calc, shapes, backgrounds}
\usepackage{amsmath, amssymb}
\pagecolor{olive!50!yellow!50!white}
%===========
\begin{document}
%===========
\tikzset{
zahl/.style={fill=blue!70!yellow, text=black, label=center:\textsf{\Large Z}},
kopf/.style={fill=orange!90!blue, label=center:\textsf{\Large K}}
}</pre>
<pre>\begin{tikzpicture}
[scale=1.5, transform shape,
thick,
every node/.style={draw, circle, minimum size=10mm},
grow=down, %Zeichenrichtung
level 1/.style={sibling distance=3cm},
level 2/.style={sibling distance=4cm},
level 3/.style={sibling distance=2cm},
level distance=1.25cm]
\node[fill=gray!40, shape=rectangle, rounded corners, minimum width = 6cm] {Münzwurf}
child{ node[shape=circle split,draw,line width=1pt,minimum size=10mm,inner sep=0mm, font=\sffamily\large, rotate=30] (Start) { \rotatebox{-30}{K} \nodepart{lower} \rotatebox{-30}{Z}}
child {node[kopf] (A) {}
child {node[kopf] (B) {}}
child {node[zahl] (C) {}}
}
child {node[zahl] (D) {}
child {node[kopf] (E) {}}
child {node[zahl] (F) {}}
}
};
%Füllung der Wurzel = "Start"
\begin{scope}[on background layer, rotate=30]
\fill[kopf] (Start.base) ([xshift=0mm]Start.east) arc (0:180:5mm)–cycle;
\fill[zahl] (Start.base) ([xshift= 0pt]Start.west) arc (180:360:5mm)–cycle;
\end{scope}
%Beschriftung
\path (Start) — (A) node [draw=none, near start, left] {$0.5$};
\path (A) — (B) node [draw=none, near start, left] {$0.5$};
\path (A) — (C) node [draw=none, near start, right] {$0.5$};
\path (Start) — (D) node [draw=none, near start, right] {$0.5$};
\path (D) — (E) node [draw=none, near start, left] {$0.5$};
\path (D) — (F) node [draw=none, near start, right] {$0.5$};
%
\node[below=11pt, draw=none, name=X] at (B) {$0.25$};
\node[below=11pt, draw=none] at (C) {$0.25$};
\node[below=11pt, draw=none, name=Y] at (E) {$0.25$};
\node[below=11pt, draw=none] at (F) {$0.25$};
%
\draw[densely dashed, rounded corners, thin] (X.south west) rectangle (Y.north east);
\end{tikzpicture}
%===========
\end{document}
%===========</pre>
\usepackage[ngerman]{babel}
\usepackage{selinput}
\SelectInputMappings{adieresis={ä}, germandbls={ß}}
\usepackage{tikz}
\usetikzlibrary{calc, shapes, backgrounds}
\usepackage{amsmath, amssymb}
\pagecolor{olive!50!yellow!50!white}
%===========
\begin{document}
%===========
\tikzset{
zahl/.style={fill=blue!70!yellow, text=black, label=center:\textsf{\Large Z}},
kopf/.style={fill=orange!90!blue, label=center:\textsf{\Large K}}
}</pre>
<pre>\begin{tikzpicture}
[scale=1.5, transform shape,
thick,
every node/.style={draw, circle, minimum size=10mm},
grow=down, %Zeichenrichtung
level 1/.style={sibling distance=3cm},
level 2/.style={sibling distance=4cm},
level 3/.style={sibling distance=2cm},
level distance=1.25cm]
\node[fill=gray!40, shape=rectangle, rounded corners, minimum width = 6cm] {Münzwurf}
child{ node[shape=circle split,draw,line width=1pt,minimum size=10mm,inner sep=0mm, font=\sffamily\large, rotate=30] (Start) { \rotatebox{-30}{K} \nodepart{lower} \rotatebox{-30}{Z}}
child {node[kopf] (A) {}
child {node[kopf] (B) {}}
child {node[zahl] (C) {}}
}
child {node[zahl] (D) {}
child {node[kopf] (E) {}}
child {node[zahl] (F) {}}
}
};
%Füllung der Wurzel = "Start"
\begin{scope}[on background layer, rotate=30]
\fill[kopf] (Start.base) ([xshift=0mm]Start.east) arc (0:180:5mm)–cycle;
\fill[zahl] (Start.base) ([xshift= 0pt]Start.west) arc (180:360:5mm)–cycle;
\end{scope}
%Beschriftung
\path (Start) — (A) node [draw=none, near start, left] {$0.5$};
\path (A) — (B) node [draw=none, near start, left] {$0.5$};
\path (A) — (C) node [draw=none, near start, right] {$0.5$};
\path (Start) — (D) node [draw=none, near start, right] {$0.5$};
\path (D) — (E) node [draw=none, near start, left] {$0.5$};
\path (D) — (F) node [draw=none, near start, right] {$0.5$};
%
\node[below=11pt, draw=none, name=X] at (B) {$0.25$};
\node[below=11pt, draw=none] at (C) {$0.25$};
\node[below=11pt, draw=none, name=Y] at (E) {$0.25$};
\node[below=11pt, draw=none] at (F) {$0.25$};
%
\draw[densely dashed, rounded corners, thin] (X.south west) rectangle (Y.north east);
\end{tikzpicture}
%===========
\end{document}
%===========</pre>
Comments
One response to “Baum von Wahrscheinlichkeiten”
Schönes Beispiel! Ich habe das nun mal auch in der TikZ-Galerie ausgestellt, auf Englisch gemacht.