YuLab-SMU / ggtree

:christmas_tree:Visualization and annotation of phylogenetic trees
https://yulab-smu.top/contribution-tree-data/
838 stars 173 forks source link

Expanded docs for geom_tiplab() #535

Open nick-youngblut opened 2 years ago

nick-youngblut commented 2 years ago

Given that tip labels will often be cut off (not fully visible) if one uses:

ggtree(tree, branch.length = 'none') + geom_tiplab() 

...with any labels larger than short numbers/letters (as is conveniently used throughout the docs), it would be helpful to provide information on how to deal with this plotting issue directly in the Details section of geom_tiplab(). It would save a lot of time searching the docs/forums for a solution.

reprex

require(ape)
tr <- rtree(10)
tr$tip.label = gsub('^', 'A long label: ', tr$tip.label)
ggtree(tr, branch.length = 'none') + geom_tiplab()

reprex

nick-youngblut commented 2 years ago

In regards to the + xlim() solution, it would be helpful to stress that the method is completely dependent on the branch lengths of the tree, so using p + xlim(0, 0.08) as described here won't work with long branch lengths, such as in:

require(ape)
tr <- rtree(10)
tr$tip.label = gsub('^', 'A long label: ', tr$tip.label)
ggtree(tr, branch.length = 'none') + geom_tiplab()

...due to branch.length = 'none'

nick-youngblut commented 1 year ago

ping

nick-youngblut commented 1 year ago

It would also be helpful to include an example in the geom_tiplab() docs that show how to create custom labels. For example: geom_tiplab(aes(label=genus))