These let you apply grafify discrete or continuous palettes as fill or colour/color aesthetics to any ggplot2 (scale_color_ spelling is also accepted).

scale_color_grafify(
  palette = "okabe_ito",
  discrete = TRUE,
  ColSeq = TRUE,
  reverse = FALSE,
  ...
)

Arguments

palette

Name of the grafify palettes from above, provide within quotes. Default discrete palette is okabe_ito. For quantitative palette, set discrete = FALSE (which will apply blue_conti unless another paltte is chosen).

discrete

logical TRUE or FALSE. Default is TRUE for discrete colour palettes. Set to FALSE when plotting quantitative data to use quantitative palettes from above.

ColSeq

logical TRUE or FALSE. Default TRUE for sequential colours from chosen palette. Set to FALSE for distant colours.

reverse

Whether the colour order should be reversed.

...

Additional parameters for scale_fill or scale_colour.

Value

ggplot scale_fill function for discrete colours.

Details

The default is palette = "okabe_ito" and discrete = TRUE. To apply quantitative colour/fill schemes set discrete = FALSE (if a palette is not chosen, blue_conti palette will be applied by default).

Categorical/discreet palettes (only allowed with discrete = TRUE)

  • okabe_ito

  • bright

  • contrast

  • dark

  • kelly

  • light

  • muted

  • pale

  • r4

  • safe

  • vibrant

By default, sequential colours from above palettes will be chosen. To choose the most distant colours set ColSeq = TRUE.

Sequential quantitative palettes (only allowed with discrete = FALSE):

  • grey_conti

  • blue_conti

  • yellow_conti

Divergent quantitative palettes (only allowed with discrete = FALSE):

  • OrBl_div

  • PrGn_div

Examples

#add a grafify fill scheme to ggplot
ggplot(emmeans::neuralgia, aes(x = Treatment, 
                               y = Duration))+
  geom_boxplot(aes(fill = Treatment), 
               alpha = .6)+
  geom_point(aes(colour = Treatment,
                 shape = Treatment), 
             size = 3)+
  scale_fill_grafify(palette = "bright")+
  scale_colour_grafify(palette = "bright")+
  facet_wrap("Sex")+
  theme_classic()

#distant colours `ColSeq = FALSE`   
ggplot(emmeans::neuralgia, aes(x = Treatment, 
                               y = Duration))+
  geom_boxplot(aes(fill = Treatment), 
               alpha = .6)+
  geom_point(aes(colour = Treatment,
                 shape = Treatment), 
             size = 3)+
  scale_fill_grafify(palette = "bright",
                     ColSeq = FALSE)+
  scale_colour_grafify(palette = "bright",
                       ColSeq = FALSE)+
  facet_wrap("Sex")+
  theme_classic()

#quantiative colour schemes with `discrete = FALSE`
ggplot(mtcars, aes(x = disp,
                   y = mpg))+
  geom_point(aes(colour = cyl), 
             size = 3)+
  scale_colour_grafify(discrete = FALSE)

#quantiative colour scheme
ggplot(mtcars, aes(x = disp,
                   y = mpg))+
  geom_point(aes(colour = cyl), 
             size = 3)+
  scale_colour_grafify(palette = "yellow_conti")