I'm trying to create a plot using ggplot2 (v. 2_2.2.1) facet_wrap
, and I need to have a Greek symbol in only one facet label (out of five). I have tried to use code posted here on Stack Overflow:
- R Greek letters and normal letters for facet label in R facet grid
- How to add expressions to labels in facet_wrap?
- How can I use grid to edit a ggplot2 object to add math expressions to facet labels?
but without any success (getGrob is not working, and that's true also for the mf_labeller).
Can anyone help me with that?
Here is the example code:
df <- data.frame(genes = rep(c("BA","MLL","pos","neg","PMLalpha+"),5), value = sample(1:100, 25, replace=TRUE))
df$genes <- factor(df$genes, levels = c("BA","MLL","pos","neg","PMLalpha+"), ordered = TRUE)
ggplot(df,aes(x=genes, y=value)) + geom_boxplot()+
facet_wrap(~genes, ncol = 5,scales = "free_x")+
scale_x_discrete(name="",
breaks = c("BA","MLL","pos","neg","PMLalpha+"),
labels = c("BA","MLL","pos","neg",expression(paste("PML", alpha,"+"))))
I'm able to rename the x-axis tick, but I just can't do that within the facet labels.