如何绘制这个树形图?

如何绘制这个树形图?

我如何在 LaTex 中绘制这种树形图? 在此处输入图片描述

答案1

欢迎来到 TeX-SE!这是给你一个开始我相信你可以还可以通过编程添加HT,但我现在没有动力去阐明这一点(更重要的是,我不确定这是否是你想要的)。

\documentclass{article} 
\usepackage[edges]{forest}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{forest}
for tree={s sep=0cm,l sep=1.2cm,font=\sffamily,
where n children=0{rotate=90,anchor=west,edge={thick,-{Latex}}}{},
edge={thick}
}
  [H,alias=L1
   [H,alias=L2
    [H,alias=L3
     [H,alias=L4
      [H,alias=L5
       [HHHHH,alias=L6]
      ]
      [T
       [HHHHT]
      ]
     ]
     [T
      [H
       [HHHTH]
      ]
      [T
       [HHHTT]
      ]
     ]
    ]
    [T
     [H
      [H
       [HHTHH]
      ]
      [T
       [HHTHT]
      ]
     ]
     [T
      [H
       [HHTTH]
      ]
      [T
       [HHTTT]
      ]
     ]
    ]
   ]
   [T
    [H
     [H
      [H
       [HTHHH]
      ]
      [T
       [HTHHT]
      ]
     ]
     [T
      [H
       [HTHTH]
      ]
      [T
       [HTHTT]
      ]
     ]
    ]
    [T
     [H
      [H
       [HTTHH]
      ]
      [T
       [HTTHT]
      ]
     ]
     [T
      [H
       [HTTTH]
      ]
      [T
       [HTTTT]
      ]
     ]
    ]
   ]
  ]
\foreach \X [count=\Y] in {First,Second,Third,Fourth,Fifth} 
{\node[anchor=east,font=\sffamily] at (L6.north|-L\Y){\X\ flip};} 
\node[anchor=east,font=\sffamily] at (L6.north){Outcome}; 
\end{forest}
\end{document}

在此处输入图片描述

*注意**:我所知道的关于森林的一切几乎都是从 cfr 的一些回答中学到的,她确实是森林大师。如果您考虑点赞此回答,请点赞她的一些回答。这样您肯定会投出应得的点赞。

\documentclass{article} 
\usepackage{adjustbox}
\usepackage[edges]{forest}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{adjustbox}{valign=t,width=0.5\textwidth}
\begin{forest}
for tree={s sep=0cm,l sep=1.2cm,font=\sffamily,
where n children=1{rotate=90,anchor=west,edge={thick,-{Latex}}}{},
edge={thick}
}
  [H,alias=L1
   [H,alias=L2
    [H,alias=L3
     [H,alias=L4
      [H,alias=L5
       [HHHHH,alias=L6
        [$5$,alias=L7]
       ]
      ]
      [T
       [HHHHT
        [$3$]
       ]
      ]
     ]
     [T
      [H
       [HHHTH
       [$3$]
       ]
      ]
      [T
       [HHHTT
        [$1$]
       ]
      ]
     ]
    ]
    [T
     [H
      [H
       [HHTHH
        [$3$]
       ]
      ]
      [T
       [HHTHT
        [$1$]
       ]
      ]
     ]
     [T
      [H
       [HHTTH
        [$1$]
       ]
      ]
      [T
       [HHTTT
        [$-1$]
       ]
      ]
     ]
    ]
   ]
   [T
    [H
     [H
      [H
       [HTHHH
        [$3$]
       ]
      ]
      [T
       [HTHHT
        [$1$]
       ]
      ]
     ]
     [T
      [H
       [HTHTH
        [$1$]
       ]
      ]
      [T
       [HTHTT
        [$-1$]
       ]
      ]
     ]
    ]
    [T
     [H
      [H
       [HTTHH
        [$1$]
       ]
      ]
      [T
       [HTTHT
        [$-1$]
       ]
      ]
     ]
     [T
      [H
       [HTTTH
        [$-1$]
       ]
      ]
      [T
       [HTTTT
        [$-3$]
       ]
      ]
     ]
    ]
   ]
  ]
\foreach \X [count=\Y] in {First,Second,Third,Fourth,Fifth} 
{\node[anchor=east,font=\sffamily] at (L6.north|-L\Y){\X\ flip};} 
\node[anchor=east,font=\sffamily] at (L6.north){Outcome}; 
\node[anchor=east,font=\sffamily] at (L7.west){Lands on}; 
\end{forest}
\end{adjustbox}
\begin{adjustbox}{valign=t,width=0.47\textwidth}
\begin{forest}
for tree={s sep=0cm,l sep=1.2cm,font=\sffamily,
where n children=1{rotate=90,anchor=west,edge={thick,-{Latex}}}{},
edge={thick}
}
  [T,alias=L1
   [H,alias=L2
    [H,alias=L3
     [H,alias=L4
      [H,alias=L5
       [THHHH,alias=L6
        [$3$,alias=L7]
       ]
      ]
      [T
       [THHHT
        [$1$]
       ]
      ]
     ]
     [T
      [H
       [THHTH
       [$1$]
       ]
      ]
      [T
       [THHTT
        [$-1$]
       ]
      ]
     ]
    ]
    [T
     [H
      [H
       [THTHH
        [$1$]
       ]
      ]
      [T
       [THTHT
        [$-1$]
       ]
      ]
     ]
     [T
      [H
       [THTTH
        [$-1$]
       ]
      ]
      [T
       [THTTT
        [$-3$]
       ]
      ]
     ]
    ]
   ]
   [T
    [H
     [H
      [H
       [TTHHH
        [$1$]
       ]
      ]
      [T
       [TTHHT
        [$-1$]
       ]
      ]
     ]
     [T
      [H
       [TTHTH
        [$-1$]
       ]
      ]
      [T
       [TTHTT
        [$-3$]
       ]
      ]
     ]
    ]
    [T
     [H
      [H
       [TTTHH
        [$-1$]
       ]
      ]
      [T
       [TTTHT
        [$-3$]
       ]
      ]
     ]
     [T
      [H
       [TTTTH
        [$-3$]
       ]
      ]
      [T
       [TTTTT
        [$-5$]
       ]
      ]
     ]
    ]
   ]
  ]
\end{forest}
\end{adjustbox}
\end{document}

在此处输入图片描述

相关内容