###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
)What in middle earth is going on here?
This seems to do the trick
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)
It also works if you replace unit(1, "native")
by a positive number, or TRUE
(I am not sure why though - probably at some point this is coerced to a default type unit, likely "npc")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With