scale_chrestos: Chrestos color scale for ggplot

scale_chrestosR Documentation

Chrestos color scale for ggplot

Description

Add a Chrestos color palette to the color or fill aesthetic of a ggplot.

Usage

scale_color_chrestos(
  palette = "main",
  discrete = TRUE,
  reverse = FALSE,
  shade = 0.5,
  customPalettes = NULL,
  ...
)

scale_fill_chrestos(
  palette = "main",
  discrete = TRUE,
  reverse = FALSE,
  shade = 0.5,
  customPalettes = NULL,
  ...
)

Arguments

palette

Name of the color palette (character). Use names(chresos_palettes()) to obtain the names of the implemented color palettes.

discrete

Use a discrete (TRUE) or continuous (FALSE) scale.

reverse

Use the selected palette in original (FALSE) or reversed (TRUE) order.

shade

Numeric vector in [0,1] that defines the brightness of the palettes. Values higher then 0.5 lead to brighter colors than the original shade, values lower than 0.5 lead to darker colors.

customPalettes

If desired, a named list of custom palettes with the same structure as chresos_palettes().

...

Further arguments to pass to discrete_scale() or scale_color_gradientn().

Examples


#color on discrete scale
iris %>%
  ggplot(aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
  geom_point(size = 4, alpha = 0.8) +
  scale_color_chrestos(palette = "minimal") +
  theme_light()

#color on discrete scale with custom palette (also works with hex codes instead of names)
my_palettes<- list(theonlyone = c("dodgerblue", "forestgreen", "firebrick", "gold"))
iris %>%
  ggplot(aes(x = Petal.Length, y = Petal.Width, color = Species)) +
  geom_point(size = 4, alpha = 0.8) +
  scale_color_chrestos(palette = "theonlyone", customPalettes = my_palettes) +
  theme_light()

#fill on continuous scale with reverse palette
faithfuld %>%
  ggplot(aes(x = waiting, y = eruptions, fill = density)) +
  geom_raster(interpolate = TRUE) +
  scale_fill_chrestos(palette = "grad4", discrete = FALSE, reverse = TRUE) +
  theme_void()


seb09/cccolr documentation built on Aug. 1, 2022, 1:49 a.m.