when we use the facet
option in ggplot, we get a beautiful grey box around the headings (3,4,5).
library(ggplot2)
data(mtcars)
ggplot(mtcars,
Since you are asking how to do it without facets, this is strictly speaking not an answer, but just to point it out, one quick and dirty way would be to "cheat" and to use a facet after all. For instance,
mtcars$title <- "How do you put a grey box around me??"
ggplot(mtcars, aes(cyl)) + geom_bar() + theme_bw() +
facet_grid(. ~ title)
does the trick.