Remove strip background keep panel border
Setting panel.border
might cover your graph unless you also add fill=NA
to panel.border
:
theme(panel.border = element_rect(fill = NA, colour = "black"))
One can also use:
theme(panel.background = element_rect(fill = NA, color = "black")
source (section "Panel Attributes")
If you set element_blank()
for strip.background
and keep element_rect(colour="black", fill = NA)
for panel.border
then top edge of panel.border
will be black.
As pointed out by @adrien, for panel.background
fill should be set to NA to avoid covering of points (already set as default for theme_bw()
).
ggplot(mtcars, aes(mpg, hp)) + geom_point() +
facet_wrap(~carb, ncol = 3) + theme_bw() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
strip.background = element_blank(),
panel.border = element_rect(colour = "black", fill = NA))