The following code will depict a phylogenetic tree with tip marks in italics, and underscores replaced with spaces.
library(ape)
tr <- rtree(5, tip.label=c("a_b_x1", "b_c_2", "c_d_3y", "d_e_4", "e_f_5"))
plot(tr)
How to combine plain text with italic text in label labels on phylogenesis? I am interested in letters in italics and the alphanumeric segment after the last underscore displayed as plain text.
I tried using expressionwith tiplabels, but this does not work due to the interpretation of indexing. Also failed to format subto select two parts in expression.
tip <- unlist(strsplit("a_b_x1", "_"))
tiplabels(expression(italic(paste(tip[1:length(tip)-1], collapse = " ")) * tip[length(tip)]),
tip = which(tr$tip.label == "a_b_x1"), frame = "n", bg = "white")
source
share