Plotmath - janeshdev/ggplot2 GitHub Wiki
Text labels
library(ggplot2)
p = ggplot(data.frame(x=1,y=1,label="alpha"))
p + geom_text(aes(x,y,label=label))
## use the parse argument to interpret the plotmath expression
( p2 = p + geom_text(aes(x,y,label=label), parse=TRUE) )
Axis labels, ...
p2 + xlab(expression(beta)) + opts(title = expression(gamma))
Facet labels
qplot(x,y, data=data.frame(x=1:2,y=1:2, f = factor(c("alpha","beta"))), geom="point") +
facet_grid(.~f, labeller= label_parsed)
Legend labels
d <- data.frame(x=1:10,y=1:10,f=rep(c("alpha","beta"),each=5), stringsAsFactors=FALSE)
value <- 3.1415
my.labs <- list(bquote(alpha==.(value)),bquote(beta==.(value)))
qplot(x,y,data=d,colour=f) +
scale_colour_manual(values=1:2,breaks=c("alpha","beta"),
labels=my.labs)