Hi there! Thanks for creating such a great package, it's been invaluable to my work.
I'm having a problem when trying to use custom tip labels (see reprex below). plot2 shows an example of successfully changing the default tip label (as shown in plot1) via changing the label aesthetic in geom_tiplab. If I then add as_ylab = TRUE (as in plot3), those custom tip labels are lost, and the tip labels revert to the defaults (as in plot1).
Can you help me understand how I can set as_ylab = TRUE without losing the custom tip labels?
This is using ggtree_3.4.1 and R Version 4.2.1
library(ggtree); library(patchwork)
#> ggtree v3.4.1 For help: https://yulab-smu.top/treedata-book/
#>
#> If you use the ggtree package suite in published research, please cite
#> the appropriate paper(s):
#>
#> Guangchuang Yu, David Smith, Huachen Zhu, Yi Guan, Tommy Tsan-Yuk Lam.
#> ggtree: an R package for visualization and annotation of phylogenetic
#> trees with their covariates and other associated data. Methods in
#> Ecology and Evolution. 2017, 8(1):28-36. doi:10.1111/2041-210X.12628
#>
#> Guangchuang Yu, Tommy Tsan-Yuk Lam, Huachen Zhu, Yi Guan. Two methods
#> for mapping and visualizing associated data on phylogeny using ggtree.
#> Molecular Biology and Evolution. 2018, 35(12):3041-3043.
#> doi:10.1093/molbev/msy194
#>
#> S Xu, Z Dai, P Guo, X Fu, S Liu, L Zhou, W Tang, T Feng, M Chen, L
#> Zhan, T Wu, E Hu, Y Jiang, X Bo, G Yu. ggtreeExtra: Compact
#> visualization of richly annotated phylogenetic data. Molecular Biology
#> and Evolution. 2021, 38(9):4039-4042. doi: 10.1093/molbev/msab166
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)
#> Scale for 'y' is already present. Adding another scale for 'y', which will
#> replace the existing scale.
plot1 + plot2 + plot3
Hi there! Thanks for creating such a great package, it's been invaluable to my work.
I'm having a problem when trying to use custom tip labels (see reprex below).
plot2
shows an example of successfully changing the default tip label (as shown inplot1
) via changing thelabel
aesthetic ingeom_tiplab
. If I then addas_ylab = TRUE
(as inplot3
), those custom tip labels are lost, and the tip labels revert to the defaults (as inplot1
).Can you help me understand how I can set
as_ylab = TRUE
without losing the custom tip labels?This is using
ggtree_3.4.1
andR Version 4.2.1
Created on 2022-08-09 by the reprex package (v2.0.1)