I\'m generating a scatterplot in which one of my categories is an \"Other\" category. I would like the other categories in my factor variable to be whatever color they are,
based on this post you can get ggplot
colors with this function:
gg_color_hue <- function(n) {
hues = seq(15, 375, length = n + 1)
hcl(h = hues, l = 65, c = 100)[1:n]
}
So in your case :
cols = gg_color_hue(length(levels(iris$Species)))
Then you reprogramm the color you want to change and use it for your plot:
cols[levels(iris$Species)=="virginica"]="gray"
p2 <- p1 + scale_color_manual(values=cols)