Description Usage Arguments Value Author(s) Examples
View source: R/tree_addLabel.R
addLabel
adds labels to the node of a tree (phylo
object)
1 |
tree |
A phylo object |
label |
A character vector as the label of tree. The label is passed to nodes that are sorted by their node number in ascending order. The default is NULL, and nodes are labeled by using their node numbers (convert node numbers from numeric values to characters) |
a phylo object
Ruizhu Huang
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
data(tinyTree)
library(ggtree)
# PLOT tree
# The node labels are in orange texts and the node numbers are in blue
ggtree(tinyTree,branch.length = 'none')+
geom_text2(aes(label = label), color = "darkorange",
hjust = -0.1, vjust = -0.7) +
geom_text2(aes(label = node), color = "darkblue",
hjust = -0.5, vjust = 0.7)
# change labels
nodes <- showNode(tree = tinyTree, only.leaf = FALSE)
tt <- addLabel(tree = tinyTree, label = LETTERS[nodes])
ggtree(tt, branch.length = 'none')+
geom_text2(aes(label = label), color = "darkorange",
hjust = -0.1, vjust = -0.7) +
geom_text2(aes(label = node), color = "darkblue",
hjust = -0.5, vjust = 0.7)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.