ggplot2 – How to change the color of each facet in a scatter plot in R?

I’m trying to visualize two bivariate quantitative variables, disaggregated by the categorical variable stu_tech_cat. I would like each facet to have a different color, but have been unsuccessful in achieving that so far. Below is my code:

tech_stu <- ggplot(mydata, aes(y = EEScore, x= subtct, fill = stu_tech_cat, color)) +
  geom_point(alpha = .3) +
  geom_smooth(method = "lm", se = FALSE) +
  facet_wrap(~stu_tech_cat) +
  scale_fill_brewer(palette = "RdPu") +
  labs(title = "Session : {closest_state}", fill = "Subject", y = "Student External Evaluation Score", x = "Teacher TCT score") +
  theme(panel.background = element_rect(colour = "ivory", fill = "ivory"),           plot.background  = element_rect(colour = "ivory", fill = "ivory")) +
  transition_states(session)
animate(tech_stu, renderer = gifski_renderer())

Will be grateful for any help.

Read more here: Source link