r - 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)
obtained result (ggplot2_2.0.0
)
expected result (ggplot2_1.0.1
)
question
what in middle earth going on here?
this seems 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 works if replace unit(1, "native")
positive number, or true
(i not sure why though - @ point coerced default type unit, "npc")
Comments
Post a Comment