If you want to add mathematical symbols to facet_wrap , you used to use the grid package, as in (an example is taken here) :
library(ggplot2); library(grid) d <- ggplot(diamonds, aes(carat, price, fill = ..density..)) xlim(0, 2) + stat_binhex(na.rm = TRUE) + opts(aspect.ratio = 1) d <- d + facet_wrap(~ color, ncol = 4) grob <- ggplotGrob(d) strip_elem <- grid.ls(getGrob(grob, "strip.text.x", grep=TRUE, global=TRUE))$name grob <- editGrob(grob, strip_elem[1], label=expression(Y[1])) grid.draw(grob)
This does not work anymore as it gives this error:
> strip_elem <- grid.ls(getGrob(grob, "strip.text.x", grep=TRUE, global=TRUE))$name Error in getGrob(grob, "strip.text.x", grep = TRUE, global = TRUE) : It is only valid to get a child from a 'gTree' > grob <- editGrob(grob, strip_elem[1], label=expression(Y[1])) Error in editGrob(grob, strip_elem[1], label = expression(Y[1])) : object 'strip_elem' not found
How to add math symbols in version 0.9.2?
source share