2

Load libraries

library(ggplot2) #Version 2.2.1
library(gtable)

Build plot

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

Aim: change height of strip text

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()

Expected result (as per the old ggplot 2.1.0)

enter image description here

Problem: Obtained result (in ggplot2 2.2.1)

enter image description here

The above solution is from here and worked fine in ggplot2 version 2.1.0.

How then should the strip background height modification be done in ggplot2 V 2.2.1? Many thanks folks!

Community
  • 1
  • 1
shekeine
  • 1,445
  • 10
  • 22
  • Isn't something like `+theme(strip.text.x = element_text(margin = margin(1, 0.5, 1, 0, "cm")))`enough? – Haboryme Feb 06 '17 at 16:16
  • As @Haboryme suggests, use `margins` in `strip,text` elements (see [here](http://stackoverflow.com/questions/41428344/edit-strip-size-ggplot2/41428958#41428958)). But, in your code, the index for the heights is 6, and the indices for the three grobs are 17, 18, and 19. – Sandy Muspratt Feb 06 '17 at 23:46

0 Answers0