Last answered:

21 Feb 2022

Posted on:

15 Feb 2022

0

Resolved: Specifying color inside a facet

Can I specify a color pallet inside a facet? For example, If I want the regions to be color-coded but in shades of blue? Or if R gives me color coding in shades of blue, but I want the circles to be of different colors?

2 answers ( 1 marked as helpful)
Instructor
Posted on:

21 Feb 2022

0

Hi Joao,
thanks for reaching out! That's a great question and one of the more advanced or custom ways to build a ggplot. There are a options to changing the colors of a ggplot scatter plot.
Option 1: enter custom colors for each category like so

sp + geom_point(aes(color = Region)) + theme_light() + 
  labs(x = "Corruption Perception Index, 2015", 
       y = "Human Development Index, 2015", 
       title = "Corruption and Human Development") + 
  scale_color_manual(values=c("red", "blue", "green", "orange", "black", "grey"))

Or alternatively, you can use a different color palette, in your question you mention blue, so that's the example I chose:

sp + geom_point(aes(color = Region)) + theme_light() + 
  labs(x = "Corruption Perception Index, 2015", 
       y = "Human Development Index, 2015", 
       title = "Corruption and Human Development") + 
  scale_color_brewer(palette="Blues")

Feel free to customize the plot further with your own colors and color palettes.

Best,
365 Eli

Posted on:

21 Feb 2022

0

Thank you so much!! Best regards

Submit an answer