Getting rid of facet_grid labels on those gray boxes?

Juan picture Juan · Mar 27, 2015 · Viewed 18.5k times · Source

What I'd like it's to remove those labels on the right side, the ones on gray boxes on the side. I'll give an example:

p <- ggplot(mtcars, aes(mpg, wt, col=factor(cyl))) + geom_point()
p + facet_grid(cyl ~ .)

enter image description here

Thanks in advance!

Juan

Answer

Ruthger Righart picture Ruthger Righart · Mar 27, 2015

The following would do that:

p <- ggplot(mtcars, aes(mpg, wt, col=factor(cyl))) + geom_point()
p <- p + facet_grid(cyl ~ .)
p <- p +theme(strip.text.y = element_blank())

Without rectangles

p <- ggplot(mtcars, aes(mpg, wt, col=factor(cyl))) + geom_point()
p <- p + facet_grid(cyl ~ .)
p <- p + theme(strip.background = element_blank(),
   strip.text.y = element_blank())

enter image description here