Home > Mobile >  geom_point - change colour of variable
geom_point - change colour of variable

Time:12-06

enter image description here

I coloured my data by "Full Bath", however it is a similar shade & unclear.

I am trying to change the colour by variable of "Full Bath" to be more clear.

Could anyone help :)

This is what I have:

data %>%
  ggplot(aes(Sale.Price, Total.Bsmt.SF))  
  geom_point(aes(colour = Full.Bath))   geom_smooth()

CodePudding user response:

To manually change the colors, you can use scale_color_manual, as follows:

### Simulation of data
set.seed(1)
data <- data.frame(Sale.Price=rnorm(100, 100, 10), 
                   Total.Bsmt.SF=rnorm(100, 10, 1),
                   Full.Bath=rep(c("a", "b", "c", "d", "e"), 20))

### Plot data
data %>%
  ggplot(aes(x = Sale.Price, y = Total.Bsmt.SF))  
  geom_point(aes(colour = Full.Bath))   
  geom_smooth()   
  scale_color_manual(values=c("#84d58d", "#84c1d5", "#9e84d5", "#d584b0", "#d5be84"))

enter image description here

Link for colors selection https://htmlcolorcodes.com/fr/

  • Related