Adapting this answer .
A little better. Design your own width.
library(reshape2) library(ggplot2) library(grid) library(gtable) p = ggplot(tips, aes(x=total_bill, y=tip/total_bill)) + geom_point(shape=1) + facet_grid(sex ~ .) # text, size, colour for added text text = "SEX" size = 30 col = "red" face = "bold" # Convert the plot to a grob gt <- ggplotGrob(p) # Get the positions of the right strips in the layout: t = top, l = left, ... strip <-c(subset(gt$layout, grepl("strip-r", gt$layout$name), select = t:r)) # Text grob text.grob = textGrob(text, rot = -90, gp = gpar(fontsize = size, col = col, fontface = face)) # New column to the right of current strip # Adjusts its width to text size width = unit(2, "grobwidth", text.grob) + unit(1, "lines") gt <- gtable_add_cols(gt, width, max(strip$r)) # Add text grob to new column gt <- gtable_add_grob(gt, text.grob, t = min(strip$t), l = max(strip$r) + 1, b = max(strip$b)) # Draw it grid.newpage() grid.draw(gt)
Original
library(reshape2) library(ggplot2) library(grid) library(gtable) p = ggplot(tips, aes(x=total_bill, y=tip/total_bill)) + geom_point(shape=1) + facet_grid(sex ~ .)

source share