[英]Suppress one x-axis, keep the other with ggtree and geom_facet
我正在嘗試從一個 plot 中刪除 x 軸(左側的樹應該沒有 x 軸標簽、刻度、線條等),同時將 x 軸保留在右側的 plot 上(0- 60,滴答聲,label:“G 的數量”)。 我搜索了幾乎所有的 ggtree 博客,ggtree github,ggplot2 幫助,ggtree 幫助等都沒有成功。
其他人在這里尋找相同問題的答案: https://groups.google.com/g/bioc-ggtree/c/CPb1C955PHo 。
p <- ggtree(phylo) + geom_tiplab(offset=1, hjust=.8, size=2.5) +
geom_facet(panel="GS", data=res3, geom = ggstance::geom_barh,
mapping = aes(x= Freq,group= as.factor(res3$CG),fill= GS),
color='grey90', lwd=.3, stat="identity") +
theme_tree2(legend.position=c(.85, .45)) +
scale_x_continuous(breaks = c(0,5,10,15,20,30,40,50,60)) +
theme(strip.background = element_blank(), strip.text = element_blank()) +
scale_fill_manual(name = "GS", values=c("#0072B2", "#D55E00", "#E69F00", "#F0E442", "#999999", "#009E73"))
p
我想到了。
phylop <- ggtree(phylo) + geom_tiplab(offset=0.1, hjust=0, size=2.5) + xlim_tree(5.3)
bars <- ggplot(res3, aes(y= Freq,x= as.factor(CG))) + geom_col(aes(fill=GS)) +
# geom_text(aes(label=CG, y= Freq)) +
coord_flip() +
scale_y_continuous(breaks = c(0,1,2,3,4,5,10,15,20,30,40,50,60)) +
theme_tree2() + theme(legend.position=c(.70, .65)) +
scale_fill_manual(name = "GS", values=c("#0072B2", "#D55E00", "#E69F00", "#F0E442", "#999999", "#009E73"))
cowplot::plot_grid(phylop, bars, ncol=2)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.