color for graph in ggplot2

hi everyone,
for an exam in my data science course i been ask to use 'ggplot2movies' package and create a graph with the data. i wrote the code and i want to change the color of the 'rating' scale. i try some diffrent ways but it didn't work. anybody have an idea? :sweat_smile: :pray:
Rplot

this the code i wrote

What do you want to change the color to? By default, ggplot will map continuous variables in the color aesthetic to a scale from black to blue, but there are many options for using other palettes.

The default in ggplot is equivalent to:

ggplot(mtcars, aes(wt, mpg, color = disp)) +
   geom_point(size = 5) +
   scale_color_gradient(low = "#1A334B", 
                        high = "#5EB7F8", 
                        guide = "colourbar")

Rplot279

The simplest thing might be to change the "high" value to another color:

ggplot(mtcars, aes(wt, mpg, color = disp)) +
  geom_point(size = 5) +
  scale_color_gradient(low = "gray10", 
                       high = "red", 
                       guide = "colourbar")


Here are some related resources with more palette options:

1 Like

Hi, first of all thanks😊
I want to use different colour for each level.for example:
0-3: red
4-7: blue
8-10: green.
i will look in the links you send.

make sure to looked at binned scales:

ggplot(mtcars, aes(wt, mpg, color = mpg)) +
geom_point(size = 5) +
scale_color_binned(breaks=c(15,20,30))

this is great. thank you :blush: :clap:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.