Is there any way to control the size of the strips on facets in a ggplot? I tried using strip.background=element_rect(size=n)
but as far as I can tell it didn't actually do anything. Is this even possible?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
converting the plot to a gtable manually lets you tweak the strip height,
library(ggplot2)
library(gtable)
d <- ggplot(mtcars, aes(x=gear)) +
geom_bar(aes(y=gear), stat="identity", position="dodge") +
facet_wrap(~cyl)
g <- ggplotGrob(d)
g$heights[[3]] = unit(1,"in")
grid.newpage()
grid.draw(g)