[Tex/LaTex] Square Edge and Horizontal Tree Diagramm with forest

diagramsforesttrees

I am basically trying to re-create the Aves Cladogram as illustrated in this wikipedia page.

After trying to use Newicktree package for a while, I decided to migrate to forest.

I am trying to make an horizontal and squared edge tree combining answer from Square edges in forest package and how could we create this tree diagram?.

Here is my current code:

\documentclass[tikz]{standalone}
\usepackage{forest}

\begin{document}
\begin{forest}
for tree={
    edge path={\noexpand\path[\forestoption{edge}](\forestOve{\forestove{@parent}}{name}.parent anchor) -- +(0,-12pt)-|     (\forestove{name}.child anchor)\forestoption{edge label};},
    grow=0,
    reversed, % tree direction
    parent anchor=east,
    child anchor=west, % edge anchors
}
[VP
    [DP,tier=word]
    [V’
        [V,tier=word]
        [DP,tier=word]
    ]
]
\end{forest}

\end{document}

And as expected the result is not desirable:

Imgur

My guess is that I should modify -- +(0,-12pt)-|, but I don't know how !
Many thanks for your help !

Best Answer

Your answer will work but is needlessly verbose as you can simply use relative node names to specify the edge path.

      \noexpand\path[\forestoption{edge}](!u.parent anchor) -- +(5pt,0) |- (.child anchor)\forestoption{edge label};},

(!u) refers to the parent of the current node. () refers to the current node.

You can also align the terminal nodes for the whole tree in the preamble:

    if n children=0{tier=word}{}

but anchoring the nodes at the left side makes for a neater tree:

    anchor=west,

The result:

neater tree

Complete code:

\documentclass[tikz]{standalone}
\usepackage{forest}

\begin{document}
\begin{forest}
for tree={
    edge path={
      \noexpand\path[\forestoption{edge}](!u.parent anchor) -- +(5pt,0) |- (.child anchor)\forestoption{edge label};},
    grow=0,
    reversed, % tree direction
    parent anchor=east,
    child anchor=west, % edge anchors
    anchor=west,
    if n children=0{tier=word}{}
}
[VP
    [DP]
    [V’
        [V]
        [DP]
    ]
]
\end{forest}
\end{document}
Related Question