I need to draw a decision tree for my LaTeX document (with TikZ/forest
or any other package). I searched around for a while to find something similar, but found none. The decision tree produced should be like the one shown in the figure bellow.
Any help/hint would be very much appreciated.
This is what I managed to do so far, of course the shape of the tree does not have to be exactly the same as the one in picture.
\documentclass[margin=10pt]{standalone}
\usepackage{tikz,forest}
\usetikzlibrary{arrows.meta}
\begin{document}
\tikzset{
decision/.style={diamond, minimum height=10pt, minimum width=10pt, inner sep=1pt},
chance/.style={circle, minimum width=10pt, draw=blue, fill=none, thick, inner sep=0pt},
}
\begin{forest}
label L/.style={
edge label={node[midway,left,font=\scriptsize]{#1}}
},
label R/.style={
edge label={node[midway,right,font=\scriptsize]{#1}}
},
for tree={
child anchor=north,
for descendants={
{edge=->}
}
},
[$x_2$, decision, draw
[$x_1$, decision, draw, label L=N,
[1, rectangle, draw, label L=N, tier=bottom]
[0, rectangle, draw, label R=Y, tier=bottom]
]
[$x_3$, decision, draw, label R=Y,
[$x_1$, decision, draw, label L=N,
[1, rectangle, draw, label L=N, tier=bottom]
[0, rectangle, draw, label R=Y, tier=bottom]
]
[0, rectangle, draw, label R=Y, tier=bottom]
]
]
\end{forest}
\end{document}
Thank you in advance
forest
ortikz-tree
solution and we will be happy to help you with any issue, you find. Like this, it is just a "do it for me" post.