set.seed(2020)
x <- rtree(30)
d <- data.frame(label=x$tip.label, var1=abs(rnorm(30)), var2=abs(rnorm(30)))
tree <- full_join(x, d, by='label')
trs <- list(TREE1 = tree, TREE2 = tree)
class(trs) <- 'treedataList'
ggtree(trs) + facet_wrap(~.id) +
geom_tippoint(aes(subset=.id == 'TREE1', colour=var1)) +
scale_colour_gradient(low='blue', high='red') +
ggnewscale::new_scale_colour() +
geom_tippoint(aes(colour=var2), data=td_filter(.id == "TREE2")) +
scale_colour_viridis_c()
Data Integration, Manipulation and Visualization of Phylogenetic Trees 书中的第4.4.1处代码有bug
修改
geom_tippoint(aes(subset=.id == 'TREE1', colour=var1))为geom_point2(aes(subset = .id == "TREE1" & isTip, colour = var1))