rggplot2color-blindnessggthemes

chose colors for scale_colour_colorblind() in ggthemes


I would like to chose specific colors of the colorblind_pal() from ggthemes

This works:

library(ggplot2)
library(ggthemes)

p <- ggplot(mtcars) + geom_point(aes(x = wt, y = mpg,
                                     colour = factor(gear))) + facet_wrap(~am)
p + theme_igray() + scale_colour_colorblind()

Now I would like to chose specific colors of the colorblind_pal() for my plot. How can I chose them?

I tried following with no success:

my_palette <- palette(c("#000000","#F0E442","#D55E00"))
p + theme_igray() + scale_colour_colorblind(my_palette)

Solution

  • You could use scale_color_manual in order to manually specify the colors to use:

    library(ggplot2)
    library(ggthemes)
    
    p <- ggplot(mtcars) +
      geom_point(aes(x = wt, y = mpg, colour = factor(gear))) +
      facet_wrap(~am) +
      theme_igray() +
      scale_color_manual(values = c("#000000","#F0E442","#D55E00"))
    p