0

I am using the same facets to divide into stations my dataset. I have done three graphs this way, and I would like to arrange the three graphs in a single plot, I have done it with ggarange() in ggpubr, but I'd like to remove the facet labels because they are redundant (keep them in the first row only). I'll show a minimal reproducible example with dataset 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 
)

It would be like this. setosa, vresicolor and virginica appear several times, which is redundant

I want to take out the facet labels in rows 2 and 3 since it is redundant.

Thank you.

Javi_VM
  • 505
  • 2
  • 10
  • Possible duplicate of [Remove facet\_wrap labels completely](https://stackoverflow.com/questions/10547487/remove-facet-wrap-labels-completely) – tjebo Jul 04 '18 at 16:08

2 Answers2

1

I would take this in a different approach
First put your data in a correct format, and then facet using 2 variables.

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)

enter image description here

tjebo
  • 21,977
  • 7
  • 58
  • 94
  • This is very interesting since one makes full use of the grammar of graphics. However, I would like to have a separte Y-label and probably different scales depending on the row (since it represents different variables in the Y-axis). – Javi_VM Jul 09 '18 at 15:17
  • @Javi_VM but the y-axis is basically labelled with the facet strips on the right side?... for different scales, use `scales` parameter within facet – tjebo Jul 09 '18 at 15:53
0

Add

 + theme(strip.text = element_blank())

to the plots you don't wnat the face labels on

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")

Or in whichever order you want them

MHammer
  • 1,274
  • 7
  • 12