1

I want to replicate the following probability tree in tikz. My problem so far was that the nodes of different third level branches joined.

Furthermore, how can I add the text to the branches, such that it is plain horizontal and not in direction of the branch?

Is there anyone who can help me on this?

enter image description here

Simon Z.
  • 153
  • What did you try so far? Please provide a MWE (minimal working example, i.e., a complete but small latex document) that demonstrates the problems you encounter. In this case you might need to look into the child{ node {}} syntax of Tikz in combination with sibling distance and level distance options. See http://www.texample.net/tikz/examples/feature/trees/ for various examples. – Marijn Oct 14 '15 at 08:56

1 Answers1

1

Here's a forest solution:

probability tree

For an introduction to forest and the bracket notation it uses to specify trees, see the second part of my answer to an earlier question.

Code:

\documentclass[tikz,border=10pt]{standalone}
\usepackage{forest}
\begin{document}
\tikzset{
  labelling/.style={inner sep=1.5pt, font=\footnotesize\sffamily, align=left}
}
\begin{forest}
  make label/.style={
    if n=1{
      edge label={node[midway, below, anchor=north east, labelling] {#1}}
    }{
      edge label={node[midway, above, labelling, anchor=south east] {#1}}
    }
  },
  for tree={
    grow=east,
    l sep+=15mm,
    parent anchor=east,
    child anchor=west,
    delay={
      if n children=0{
        if content={}{}{
          labelling,
          anchor=west,
          for parent={
            tier=not quite terminus,
            for tree={
              calign=midpoint
            },
          },
        }
      }{
        shape=coordinate
      }
    },
  }
  [, for tree={calign=fixed edge angles}, tikz={\draw [densely dashed] (!11) +(0,-7.5mm) node [below, labelling] {once per day} -- (!ll) -- +(0,7.5mm);}
    [, make label={Some event\\or other occurs\\sometime\\$p=\alpha$}
      [
        [Some further thing]
        [And another one]
      ]
      [, phantom]
    ]
    [, make label={Some other\\event or other\\occurs sometime\\$p=1-\alpha$}
      [, make label={Something\\$p=\delta$}
        [Something here]
        [Something else]
      ]
      [, make label={Something else\\$p=1-\delta$}
        [Some other thing]
        [Another thing else]
      ]
    ]
  ]
\end{forest}
\end{document}
cfr
  • 198,882