我曾经尝试使用这个解决方案(如何在ggplot中更改facet上条带的大小?1)来更改 ggplot 中 facets 上条带的大小,我已经增加了高度大小。
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(5,"in")
grid.newpage()
grid.draw(g)
这就是我得到的结果,它只会增加条带顶部的空白部分 (白色):
为什么它的工作方式不同呢?
ggplot2
的较新版本已经重新设计了分面系统,因此这不再起作用。 - Axeman