YuLab-SMU / ggtree

:christmas_tree:Visualization and annotation of phylogenetic trees
https://yulab-smu.top/treedata-book/
833 stars 173 forks source link

fix a bug of roundrect layout to support coord_flip and label of geom_tiplab was mapped to other variable in mapping contains when as_ylab is TRUE #523

Closed xiangpin closed 2 years ago

xiangpin commented 2 years ago
library(ggtree)
set.seed(123)
tr <- rtree(10)
ggtree(tr, layout = 'round') + layout_dendrogram() -> p1
ggtree(tr, layout = 'ellipse') + layout_dendrogram() -> p2
p1 + p2

xx

library(ggtree)
tr <- read.tree(text = "((a,(b,c)),d);")
genus <- c("Gorilla", "Pan", "Homo", "Pongo")
species <- c("gorilla", "spp.", "sapiens", "pygmaeus")
geo <- c("Africa", "Africa", "World", "Asia")
d <- data.frame(label = tr$tip.label, genus = genus,
                species = species, geo = geo)
plot1 <- ggtree(tr) +
  geom_tiplab() +
  xlim(NA, 5)
plot2 <- ggtree(tr) %<+% d + 
  geom_tiplab(aes(label=genus)) +
  xlim(NA, 5)
plot3 <- ggtree(tr) %<+% d + 
  geom_tiplab(aes(label=genus), as_ylab = TRUE) +
  xlim(NA, 5)

xx