ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

Expanded docs for geom_tiplab()

Open nick-youngblut opened this issue 3 years ago • 3 comments
trafficstars

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 avatar Oct 04 '22 20:10 nick-youngblut

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 avatar Oct 04 '22 22:10 nick-youngblut

ping

nick-youngblut avatar Nov 23 '22 23:11 nick-youngblut

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))

nick-youngblut avatar Nov 24 '22 00:11 nick-youngblut