Color of Points in Scatterplot does not change with color="color_name"

Hi, Anyone. New to RStudio, following along with R for Data Visualization (https://r4ds.had.co.nz/), chapter 3.3 Aesthetic Mapping. The text illustrates how to manually change the aesthetic properties of the geom, for example the color of the point.

1 ggplot(data = mpg) +
2 geom_point(mapping = aes(x=displ,y=hwy, colour="green")) # to show the points in green. No matter what color I assign, the output color of the scatterplot is pink.

Grateful for any thoughts you might have.

I found the answer with a little perseverance - and paying attention. "Set the aesthetic by name as an argument of your geom function; i.e. it goes outside of aes(). "

ggplot(data = mpg) +
geom_point(mapping = aes(x=displ,y=hwy), color="green")

This topic was automatically closed 7 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.