The accepted answer is the easiest and easiest way to achieve the desired result, but I used this question as an opportunity to learn more about working with grabs, and I thought that I would share what I learned.
To change the interval between face labels, we can manipulate the oppression that lies in it. To do this, first create a coffin plot:
library(ggplot2) library(grid) p <- ggplot(mpg, aes(displ, hwy)) + geom_point() + facet_wrap(~ cyl + drv) g <- ggplotGrob(p)
Now we can check the rodents. The facet borders are rodents from 47 to 55 (9 rot), and we notice that each grob strip is actually a table of gnomes:
g # TableGrob (21 x 15) "layout": 62 grobs # z cells name grob # 1 0 ( 1-21, 1-15) background rect[plot.background..rect.614] # 2 1 ( 7- 7, 4- 4) panel-1-1 gTree[panel-1.gTree.33] # 3 1 (12-12, 4- 4) panel-2-1 gTree[panel-4.gTree.78] # ... # 47 2 (16-16, 4- 4) strip-t-1-3 gtable[strip] # 48 2 (16-16, 8- 8) strip-t-2-3 gtable[strip] # 49 2 (16-16,12-12) strip-t-3-3 gtable[strip] # 50 2 (11-11, 4- 4) strip-t-1-2 gtable[strip] # 51 2 (11-11, 8- 8) strip-t-2-2 gtable[strip] # 52 2 (11-11,12-12) strip-t-3-2 gtable[strip] # 53 2 ( 6- 6, 4- 4) strip-t-1-1 gtable[strip] # 54 2 ( 6- 6, 8- 8) strip-t-2-1 gtable[strip] # 55 2 ( 6- 6,12-12) strip-t-3-1 gtable[strip] # 56 4 ( 4- 4, 4-12) xlab-t zeroGrob[NULL] # ...
Focusing on grob 47, we can expand the structure ...
str(g$grobs[[47]], m = 1) str(g$grobs[[47]]$grobs, m = 1) str(g$grobs[[47]]$grobs[[1]], m = 1) str(g$grobs[[47]]$grobs[[1]]$children, m = 1) str(g$grobs[[47]]$grobs[[1]]$children[[2]], m = 1) str(g$grobs[[47]]$grobs[[1]]$children[[2]]$children, m = 1)
... until we find out how facet labels are indicated:
str(g$grobs[[47]]$grobs[[1]]$children[[2]]$children[[1]], m = 1) # List of 11 # $ label : chr "8" # $ x :Class 'unit' atomic [1:1] 0.5 # .. ..- attr(*, "valid.unit")= int 0 # .. ..- attr(*, "unit")= chr "npc" # $ y :Class 'unit' atomic [1:1] 0.5 # .. ..- attr(*, "valid.unit")= int 0 # .. ..- attr(*, "unit")= chr "npc" # $ just : chr "centre" # $ hjust : NULL # $ vjust : NULL # $ rot : num 0 # $ check.overlap: logi FALSE # $ name : chr "GRID.text.322" # $ gp :List of 6 # ..- attr(*, "class")= chr "gpar" # $ vp : NULL # - attr(*, "class")= chr [1:3] "text" "grob" "gDesc"
Now we can simply change the value for y so that the label of the upper oppression is at the base and the label for the lower block is near the top. I do this only for facet strips in the leftmost columns so that we can see the difference:
for (i in c(47, 50, 53)) { g$grobs[[i]]$grobs[[1]]$children[[2]]$children[[1]]$y = unit(0.1, "npc") g$grobs[[i]]$grobs[[2]]$children[[2]]$children[[1]]$y = unit(0.9, "npc") } grid.newpage() grid.draw(g)
Output: 