# How to generate labels next to junctions and avoid self-collision with tikz?

I have an ASCII-art phylogenetic tree that looks (in part) like

/------ PLN
/-----+ 0.9
|     \------ IL1
/--------+ 1.8
|        |      /----- PVD
|        \------+ 0.8
|               \----- URYD
--+ 3.1
|                /----- PHB
|             /--+ 0.7
|             |  \----- FLP
\-------------+ 0.8
\----- PQR

I think I understand how to use the level distance command on the children to get different depths on each side of the branch, and the grow right command to get the tree in the proper orientation, but can I get the numbers to appear as shown here--to the right of the joining node? Should these be the text of some style of node, or are they labels on textless nodes, or...?

Also, as shown here, the subtrees are different from each other and asymmetric. At this point, am I better off just drawing nodes by hand without any tree, or is there an effective way to avoid collisions?

-

forest offers a label option which can be used for this and makes quite a neat tree from very compact code. I'm not sure just how the tree should look so this may not be quite right, but it can be modified fairly easily.

\documentclass[tikz, border=5pt]{standalone}
\usepackage{forest}

\begin{document}

\begin{forest}
/tikz/label position=right,
/tikz/label distance=.5em,
for tree={
grow=0,
align=left,
parent anchor=east,
child anchor=west,
anchor=west,
before typesetting nodes={
if content={}{
shape=coordinate}{}
},
edge path={
\noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) -- +(5pt,0) |- (.child anchor)\forestoption{edge label};
},
if n children=2{
for children={
edge={rounded corners},
},
}{}
}
[,
[, label=3.1
[, label=0.8
[PQR]
[, label=0.7
[FLP]
[PHB]
]
]
[, label=1.8
[, label=0.8
[URYD]
[PVD]
]
[, label=0.9
[IL1]
[PLN]
]
]
]
]
\end{forest}

\end{document}

-
That's great! If I do this again, this does exactly what I want, so I will surely use this. (I may end up drawing my own in SVG for other reasons, however.) –  Rex Kerr Jun 28 at 23:58
@RexKerr I'm a bit of a fan of forest ;). –  cfr Jun 29 at 0:07

Textless node seems the easiest idea.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[edge from parent path={
(\tikzparentnode.east) -- ++ (2mm,0) [rounded corners] |- (\tikzchildnode.west)
}
]
\node (root) {} [grow=right]
child
child {
child {coordinate (special)}
child
};
\node[label={[inner sep=1mm]0:Label}] at (root-2) {};
\end{tikzpicture}
\end{document}

-
Thanks! This is what I ended up doing, though I had to manually keep track of the height of the two halves of each tree and use custom sibling distance on every node. (By "manually" I mean that the code that I wrote to generate the tikz commands kept track, instead of tikz doing it.) –  Rex Kerr Jan 22 '12 at 5:03