Move facet_wrap label before y axis label

Suppose I have this dataframe:

x <- seq(-10, 9.9, by = .1)
y <- seq(0, 19.9, by = .1)
z <- rep(c(1,2,3,4),each=50)

df <- data.frame(col_x = x,
                 col_y = y,
                 col_z = z)

and I plot it as such:

ggplot(df, aes(x = col_x, y = col_y))+
  geom_point()+
  facet_wrap(~col_z, strip.position = "left", nrow = 4)+
  theme(axis.title.y = element_blank(),
        strip.text.y.left = element_text(angle=0))

However, in this plot, the facet labels are after the y axis. How do I make it so that the facet labels come before the y axis. In other words, they are further left?

As it turns out, I can add

ggplot(df, aes(x = col_x, y = col_y))+
  geom_point()+
  facet_wrap(~col_z, strip.position = "left", nrow = 4)+
  theme(axis.title.y = element_blank(),
        strip.text.y.left = element_text(angle=0),
        strip.placement = "outside")

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.