require(ggplot2)
## Loading required package: ggplot2
require(grid)
## Loading required package: grid
p <-
ggplot(data.frame(a=c(1,1),b=c(1,1),c=c(1,2)), aes(a, b)) +
geom_point() +
facet_wrap(~ c) +
theme(strip.text.x=element_text(lineheight=4, color='red'))
element_grob.element_custom <- function(element, label="", ...) {
g1 <- textGrob(label, ...)
height <- max(grobHeight(g1), element$height)
gTree(children=gList(g1), height=height, cl = "custom_strip")
}
# give a height
grobHeight.custom_strip = heightDetails.custom_strip = function(x, ...)
x$height
# silly wrapper to fool ggplot2's slightly paranoid checks...
strip_custom <- function(..., height=unit(1, "line")){
structure(
list(...,height=height), # this ... information is not used, btw
class = c("element_custom","element_blank", "element") # inheritance test workaround
)
}
p + theme(strip.text.x = strip_custom(height=unit(3,"line")))