YuLab-SMU / ggtree

:christmas_tree:Visualization and annotation of phylogenetic trees
https://yulab-smu.top/contribution-tree-data/
839 stars 172 forks source link

Hilight gradient and round rectangular high light #444

Closed xiangpin closed 3 years ago

xiangpin commented 3 years ago
library(ggtree)
set.seed(1024)
tree <- rtree(60)
dat <- data.frame(id=c(62, 98),  type = c("A", "B"))
p <- ggtree(tree)
p6 <- p + geom_hilight(data=dat, mapping=aes(node=id, fill=type), gradient = TRUE, alpha=0.68)
p7 <- p + geom_hilight(data=dat, mapping=aes(node=id, fill=type), gradient = TRUE, gradient.direction="tr", alpha=0.68)
p8 <- p + geom_hilight(data=dat, mapping=aes(node=id, fill=type), roundrect = TRUE, alpha=0.68)
p6/ p7/ p8

xx

GuangchuangYu commented 3 years ago

awesome.

BastienBennetot commented 3 years ago

Great, Thanks!

GuangchuangYu commented 3 years ago
## type can be 'encircle' or 'rect'
pg + geom_hilight(node=55) + 
  geom_hilight(node=35, fill='darkgreen', type="rect")

image

since there is already a parameter called type, I think you should utilize it to reduce the number of parameters.

e.g., using type = 'roundrect' and type = 'gradient' that equivalent to current gradient = TRUE and roundrect = TRUE.