I'm looking for a way to create a simple horizontal probability tree with tikz similar to this one:

enter image description here

I saw a few examples on texample.net, but no one shows me how to create the each paths horizontally.


One option using the powerful forest package:



\forestset{declare toks={elo}{}}
for tree={
  s sep=2cm,
before typesetting nodes={
  for tree={content=\strut$#1$}
decision edge label/.style n args=3{
  edge label/.expanded={
decision/.style={if n=1
  {decision edge label={below}{north}{$#1$}}
  {decision edge label={left}{east}{$#1$}}
delay={for descendants={
  decision/.expanded/.wrap pgfmath arg={\getsecond#1\endget}{content},
  content/.expanded/.wrap pgfmath arg={\getfirst#1\endget}{content},
          [; ,no edge] [A;\frac{5}{9},elo={xshift=-3pt}] 
        ] [A;\frac{5}{8},elo={xshift=-3pt}]
      ] [A;\frac{5}{7},elo={xshift=-3pt}] 
    ] [A;\frac{5}{6},elo={xshift=-3pt}]
  ] [A;\frac{5}{5},elo={xshift=-3pt}]


enter image description here

  • Wow, nice solution. Thank you for sharing this! :) – mrpink Feb 13 '14 at 18:54

Another forest solution. This one is for basic forest users while they try to understand Gonzalo's excellent answer.

\tikzset{nicelabel/.style={midway, font=\scriptsize}}

[ \phantom{$\overline{A}$},for tree={calign=first, grow=0}
    [$\overline{A}$, edge label={node[nicelabel, below]{$\frac{4}{9}$}} 
        [$\overline{A}$, edge label={node[nicelabel,below]{$\frac{3}{8}$}} 
            [$\overline{A}$, edge label={node[nicelabel,below]{$\frac{2}{7}$}} 
                [$\overline{A}$,  edge label={node[nicelabel,below]{$\frac{1}{6}$}}
                [\phantom{$\overline{A}$}, no edge] [A, edge label={node[nicelabel,above]{$\frac{5}{5}$}}]] 
                [A, edge label={node[nicelabel,above]{$\frac{5}{6}$}}]] 
            [A, edge label={node[nicelabel,above]{$\frac{5}{7}$}}]] 
        [A, edge label={node[nicelabel,above]{$\frac{5}{8}$}}]]
    [A, edge label={node[nicelabel,above]{$\frac{5}{9}$}}]]

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.