在 ggplot2 中更改条形文本背景的高度无法按预期工作

Changing height of strip text background in ggplot2 does not work as expected

###Load libraries

library(ggplot2)
library(gtable)

###Build plot

d <- ggplot(mtcars, aes(x=gear)) + 
            geom_bar(aes(y=gear), stat="identity", position="dodge") +
            facet_wrap(~cyl)

###Change height of strip text

g <- ggplotGrob(d)
g$heights[[3]] = unit(2,"in")
grid.newpage()
grid.draw(g)

得到的结果(ggplot2_2.0.0

预期结果(ggplot2_1.0.1

问题

中土世界这是怎么回事?

这似乎可以解决问题

g <- ggplotGrob(d)
g$heights[[3]] = unit(2,"in")
g$grobs[[5]]$heights <- g$grobs[[6]]$heights <-
    g$grobs[[7]]$heights <- unit(1, "native") # or "npc"
grid.newpage()
grid.draw(g)

如果您将 unit(1, "native") 替换为正数或 TRUE,它也有效(我不确定为什么 - 可能在某些时候这被强制为默认类型单位,可能 "npc")