Adding greek symbols to legend ggplot (more than one)

Maybe this. You can smartly use paste() to concatenate the elements and add the , using expression() function:

library(ggplot2)
#Code
d <- data.frame(x=1:10,y=1:10,f=rep(c("alpha","beta"),each=5), stringsAsFactors=FALSE)
value <- 3.1415
my.labs <- c(expression(paste(alpha==1,',',~gamma==2)),expression(beta))
#Plot
qplot(x,y,data=d,colour=f) +
  scale_colour_manual(values=1:2,breaks=c("alpha","beta"),
                      labels=my.labs)

Output:

enter image description here

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top