0

I am making a plot

p <- qplot(mpg, wt, data = mtcars, colour = cyl)
p + labs(colour = "Cylinders")

here, I get a picture with legend "Cylinders", and values 2,4,6,8,10. Can I change those values to "two", "four"...etc without going back to the dataset to change the names?

Thank you

Ananta
  • 3,671
  • 3
  • 22
  • 26

1 Answers1

0
qplot(mpg, wt, data = mtcars, colour = cyl) +
  labs(colour = "Cylinders") + 
  scale_colour_gradient(breaks = 4:8, 
                        labels = c("four", "five", "six", "seven", "eight"))

enter image description here

Sven Hohenstein
  • 80,497
  • 17
  • 145
  • 168