How can I change the size of the strip on facets i

2020-02-10 04:42发布

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?

标签: r ggplot2
1条回答
一纸荒年 Trace。
2楼-- · 2020-02-10 05:23

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)
查看更多
登录 后发表回答