By default, on a faceted ggplot (facet_grid), the y-axis facet labels are on the right and the y-axis breaks and labels are on the left.
Is it possible to switch the
As ggplot2 is based on grid graphics, using the gridExtra package you can "swich" side for the facet strips in ggplot. The only painful about this approach is manually determining the coordinates. for the text.
# Some data
d <- data.frame(expand.grid(a=1:2,b=1:2,c=1:2),x=rnorm(8), y=rnorm(8))
# ggplot
p <- ggplot(d, aes(x, y)) +
geom_point() +
facet_grid(a~b) +
xlab("") +
ylab("") +
theme(strip.background = element_blank(),
strip.text = element_blank())
# Add x and y labels
p <- arrangeGrob(p, sub = textGrob(label = c("1", "2"), x = c(0.29, 0.73),
hjust = -0.1, vjust = -0.8, gp = gpar(fontsize = 10)), left = textGrob(label =
c("1", "2"), y = c(0.27, 0.70), hjust = 0, vjust = 1.8,
gp = gpar(fontsize = 10, lineheight = 0.5), rot = 90))
# View
p