Please forgive the very specific question that may not help many others. I need a kind of decision tree drawn. I am struggling with control.
I started with a dot (graphviz) tree. After a lot of tinkering, I got it almost to where I wanted it to be...
except that a bug in graphviz messes up the placement of the arrows on the far right going into the cascade box: C3R4 should be between C3R3 and C3R5, not above C3R1. (C2R1 should be higher up, too.) [please ignore box color.] graphviz was so close, but no cigar.
after experimenting with converting it into tikz via dot2tex
, I gave up and decided to go native with tikz instead.
as usual, I tried to find a similar example on the web and modify it. my best result was
\documentclass[border=30pt]{standalone}
\usepackage{charter}
\usepackage{tikz}
\usetikzlibrary{arrows}
\tikzset{
treenode/.style = {shape=rectangle, rounded corners, draw, align=center,
top color=white, bottom color=blue!20},
root/.style = {treenode, font=\Large, bottom color=red!30},
fancy/.style = {circle,draw},
prect/.style = {rectangle,draw},
dot/.style = {draw},
}
\begin{document}
\begin{tikzpicture}
[
grow = right,
sibling distance = 10em,
level distance = 10em,
edge from parent/.style = {draw, -latex},
% every node/.style = {font=\footnotesize},
sloped %% for the labels, according to angle of link
]
\node [root] {START}
child {
node [fancy] {R11}
edge from parent node [below] {$\ell1$}
}
%
child {
node [fancy] {A11}
child {
node [prect] {coin}
child {
node [fancy] {R33}
child { node {A4L5} } % edge from parent node [above] {$h2XA5$}
child { node {A4L6} } % edge from parent node [above] {$h2XA6$}
edge from parent node [below] {1/2}
}
child {
node [fancy] {A32}
child {
node {A4X1} } % edge from parent node [above] {$h35$}
child {
node {A4X2} } % edge from parent node [above] {$h36$}
edge from parent node [above] {1/2}
}
edge from parent node [below] {$\ell2$}
}
%
child {
node [dot] {}
child {
node [fancy] {A31}
child { node {A41} }
child { node {A42} }
}
edge from parent node [above] {h2}
}
edge from parent node [above] {$h1$}
};
\end{tikzpicture}
\end{document}
this got me to
not even a cigarette now
- I need the little rectangle between C1R1 and C2R1 to disappear (and C2R1 needs to remain above C2R2);
- I need C2R1 to be higher up (and still link to C3R1 and C3R2);
- I need C2R2 to continue to link to C3R3 and C3R4 nearby;
- I obviously don't want C3R6 and C3R4 to share a slot.
- I have not even gotten to attempting to draw the dashed box with text around C3R1 through C3R4.
I tried sibling angle=xx
on some child nodes, but this seemed to be ignored. (level distance worked.) I also have not gotten to visual fine-tuning yet, which sibling angle and level distance could help with.
Nuisance: how do replace the circles with (fatter) ovals?
advice highly appreciated...