ggpairs: changing default colors

I'm using ggpairs and I need to change the default color schema. Suppose I want to specify that Setosa is blue, Versicolor is green and Virginica is red. Ho can I tell ggpairs that? The entire plot (upper, lower and diag) may reflect this choice. Look at the picture and code below, please. I tried many solutions without success.

ggpairs(iris, mapping = aes(color = Species))

Hi @Kirk,
Welcome to the RStudio Community Forum.

Changing the ggpairs colour scheme is not easy. Code that you might think looks reasonable, doesn't work:

library(GGally)
my_colors <- c("setosa" = "blue", "versicolor" = "green", "virginica" = "red")
ggpairs(iris, aes(color = Species)) +
  scale_fill_manual(values = my_colors)

There is a messy work-around if you are really keen (caveat emptor):
https://stackoverflow.com/questions/22237783/user-defined-colour-palette-in-r-and-ggpairs

HTH

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