Prior to 2.0 in ggplot2, I could use element_blank and labeller to indicate only rows or columns in facet_grid , for example:
library(ggplot2) g <- ggplot(mtcars) + geom_point(aes(mpg, cyl)) g + facet_grid(vs ~ gear, labeller=labeller(vs = element_blank(), gear = label_bquote(mu == .(x))))
Now, with ggplot2 version 2.0, this does not work, providing
Error in if (attr(labels, "facet") == "wrap") { : argument is of length zero Calls: <Anonymous> ... lapply -> FUN -> <Anonymous> -> x -> resolve_labeller
Although the improvements are improved in label_bquote , is there a way to do the above labeller work?
I tried:
1) passing NULL , but by default it borders on label_value (according to ?label_bquote )
g + facet_grid(vs ~ gear, labeller = label_bquote( rows = NULL, cols = mu == .(gear)))
2) passing by element_blank , but the faces say element_blank()
g + facet_grid(vs ~ gear, labeller = label_bquote( rows = element_blank(), cols = mu == .(gear)))
3) wrapper element_blank in as_labeller
g + facet_grid(vs ~ gear, labeller=labeller(.rows = as_labeller(element_blank()), .cols = label_bquote(mu == .(gear))))
Note you can remove facet labels after the fact using the subject
g + facet_grid(vs ~ gear, labeller = label_bquote(cols = mu == .(gear))) + theme(strip.text.y = element_blank())
But I would like to do this with a labeller .