使用以下R代码,我在一个图上生成了多个图。合并多个图的x轴和图例
library(ggplot2)
Adata=nt.df[(nt.df$Species=='Human' | nt.df$Species=='Arabidopsis')& nt.df$Nucleotide=='A',]
Cdata=nt.df[(nt.df$Species=='Human' | nt.df$Species=='Arabidopsis')& nt.df$Nucleotide=='C',]
Gdata=nt.df[(nt.df$Species=='Human' | nt.df$Species=='Arabidopsis')& nt.df$Nucleotide=='G',]
Udata=nt.df[(nt.df$Species=='Human' | nt.df$Species=='Arabidopsis')& nt.df$Nucleotide=='U',]
# Grouped
Aplot <- ggplot(data, aes(fill=Species, y=Percent, x=Position)) +
geom_bar(position="dodge", stat="identity")
Cplot <- ggplot(data, aes(fill=Species, y=Percent, x=Position)) +
geom_bar(position="dodge", stat="identity")
Gplot <- ggplot(data, aes(fill=Species, y=Percent, x=Position)) +
geom_bar(position="dodge", stat="identity")
Uplot <- ggplot(data, aes(fill=Species, y=Percent, x=Position)) +
geom_bar(position="dodge", stat="identity")
grid.arrange(Aplot,Cplot,Gplot,Uplot,ncol=1)
如何合并x轴标记,y轴的标签,进入1 Species
传说为整个数字?
此外,将位置刻度标记标记为整个图形还是每个图形会更有意义吗?
此[R Bloggers Post](https://www.r-bloggers.com/another-rule-of-three-this- one-in-statistics /)有你想要的例子。这不是帖子的要点,但你应该能够遵循代码来看看如何得到这个。 – G5W
您应该考虑将数据合并到单个数据框中并使用'facet_wrap()',它还会合并您的轴标记。 – liborm