I am stuck with something on ggplot2 . I read most related posts, tried things, but did not find a real solution.
I want to include math expressions in the label of my facet_grids with ggplot2 .
- In the source file I can not write the name μg.L-1
- In the headers and axis I can do this, for example:
qplot(day, activity, data=a) +xlab(expression("100 µg "*.L^"-1"*"")) : this works well. How to make for facet_labels? I can set levels and rename label factors, but the expression is not taken into account, for example:
levels(a$group) <- c("control", expression("100 µg "*.L^"-1"*""))
qplot(ā¦, facets=~group)
Results:
Face label 1 is written on the graph: control
The inscription on the verge 2 is written on the chart: "100 mcg". L ^ "- 1" "" ...
and I donāt want that.
I do not want to use facet_grid(.~group, labeller=label_bquote(ā¦)) because I do not want all my labels to match the same expression. I want to edit tags one by one manually . I tried with bquote(ā¦) instead of expression(ā¦) , but the same bad result will happen.
Does anyone have any clues?
Example: I define a dataframe:
activity<- as.numeric(c("44","41","48","43","42","45","44","39", "47", "68", "88", "57")) group<-c("first","first","first","first","first","first", "second","second","second","second","second","second") day<- c("0", "0", "0", "20","20", "20","0", "0", "0", "20","20", "20" ) a<-data.frame(activity, group, day)
I will speak:
require (ggplot2)
qplot(day, activity, facets=.~group, data=a, ylim=c(25,90))

I want to change the name of the facet labels and the y axis:
levels(a$group)<- c("control", expression("100 µg "*.L^"-1"*"")) qplot(day, activity, facets=.~group, data=a, ylim=c(25,90), ylab=expression("fmol "*.µl^"-1"*""))

It works well with the y axis, however for the facet label it doesn't work ... Any hint?