6

I am plotting a graph with ggplot2 and I want to put arithmetic symbols in the legend labels (or anywhere else for that matter) such as "≥". I've tried the coding line expression(x>=y) which works well, but I don't want the character before or after the "≥". For example, with the following code:

library(ggplot2)

mtcars$carb <- factor(mtcars$carb)
ggplot(mtcars, aes(wt, mpg, group=carb)) + 
    geom_point(aes(colour=carb), size=4) + 
    scale_colour_discrete(labels=c(expression(x>=y), "2", "3", "4", "6", "8"))

I get this

enter image description here

but I want this.

enter image description here

Is there a way to do that?

user20650
  • 24,654
  • 5
  • 56
  • 91
Jyu
  • 61
  • 3

0 Answers0