I want to draw a horizontal decision tree. Can anyone help me to modify my code?
I'm new here. So if my question is not clear, pls let me know :)
Thanks a lot!
\documentclass[11pt]{article}
\usepackage{forest}
\forestset{
declare toks={elo}{}, % Edge Label Options
anchors/.style={anchor=#1,child anchor=#1,parent anchor=#1},
dot/.style={tikz+={\fill (.child anchor) circle[radius=#1];}},
dot/.default=2pt,
decision edge label/.style n args=3{
edge label/.expanded={node[midway,auto=#1,anchor=#2,\forestoption{elo}]{\strut$\unexpanded{#3}$}}
},
decision/.style={if n=1
{decision edge label={left}{east}{#1}}
{decision edge label={right}{west}{#1}}
},
decision tree/.style={
for tree={
s sep=0.5em,l=8ex,
if n children=0{anchors=north}{
if n=1{anchors=south east}{anchors=south west}},
math content,
},
anchors=south, outer sep=2pt,
dot=3pt,for descendants=dot,
delay={for descendants={split option={content}{;}{content,decision}}},
}
}
\begin{document}
\begin{forest} decision tree
[N,plain content
[I;{p_1=0.5},plain content,elo={yshift=4pt}
[{5,1};a]
[II;b,plain content
[{1,2};m]
[{2,3};n]
]
]
[II;{p_2=0.5},plain content,elo={yshift=4pt}
[;c
[{1,0};z]
[{2,2};t]
]
[;d
[{3,1};z]
[{0,0};t]
]
] {\draw[dashed](!1.anchor)--(!2.anchor) node[pos=0.5,above]{I};}
]
\end{forest}
\end{document}



rotate=90, but it didn't work. I think I put it in a wrong place.( ゚∀ ゚). – Ellis Mar 11 '19 at 11:17for tree = {grow=eastand than change anchors and edge labels positions accordingly. – Zarko Mar 11 '19 at 11:18for tree = {grow = eastin theforestsetand it works so well! Thank you! – Ellis Aug 05 '19 at 14:18