在不重复构面名称的情况下堆叠 ggplot 对象

stack ggplot objects without repeating facets names

我正在使用相同的方面将我的数据集划分为站点。我以这种方式完成了三张图,我想将这三张图排列在一个图中,我已经用 ggarange() in ggpubr 完成了它,但我想删除小平面标签,因为它们是多余的(仅将它们放在第一行)。 我将展示一个最小的可重现示例,其中包含数据集 iris:

ggarrange(
 ggplot(data=iris, aes(x=Sepal.Length, y=Petal.Length))+ geom_point()+facet_wrap(~Species)+theme(legend.position = "none"),
 ggplot(data=iris, aes(x=Sepal.Length, y=Petal.Width))+ geom_point()+facet_wrap(~Species)+theme(legend.position = "none"), #"bottom"),
 ggplot(data=iris, aes(x=Sepal.Length, y=Sepal.Width))+ geom_point()+facet_wrap(~Species)+theme(legend.position = "bottom"),
 nrow = 3 
)

我想去掉第 2 行和第 3 行的刻面标签,因为它是多余的。

谢谢。

添加

 + theme(strip.text = element_blank())

到你不想要面部标签的地块

ggplot(data=iris, aes(x=Sepal.Length, y=Petal.Length))+ geom_point()+facet_wrap(~Species)+theme(legend.position = "none") + theme(strip.text = element_blank()),
ggplot(data=iris, aes(x=Sepal.Length, y=Petal.Width))+ geom_point()+facet_wrap(~Species)+theme(legend.position = "none"), #"bottom") + theme(strip.text = element_blank()),
ggplot(data=iris, aes(x=Sepal.Length, y=Sepal.Width))+ geom_point()+facet_wrap(~Species)+theme(legend.position = "bottom")

或按您希望的顺序排列

我会用不同的方法来处理这个问题
首先以正确的格式放置您的数据,然后使用 2 个变量进行分面。

require(tidyr)
iris2 <- iris %>% gather(variable, value, Sepal.Width:Petal.Width)

ggplot(data=iris2, aes(x=Sepal.Length, y=value)) + 
  geom_point() + 
  facet_grid(variable~Species)