Skip to contents

This function provides access to the DOYPAColors palettes, which are categorized into sequential, diverging, and qualitative types. You can select a palette, define the number of colors, reverse the order, and interpolate colors as a gradient.

Usage

doypa(
  palette = NULL,
  n = NULL,
  reverse = FALSE,
  gradient = FALSE,
  type = "all",
  colorblind = FALSE
)

Arguments

palette

A character string specifying the name of the palette to use. If `NULL`, a random palette will be selected.

n

An integer specifying the number of colors to return. If `NULL`, the full palette is returned.

reverse

A logical value indicating whether to reverse the order of colors in the palette. Default is `FALSE`.

gradient

A logical value indicating whether to interpolate colors as a gradient of `n` colors between the first and last colors of the palette. If `FALSE`, returns the first `n` colors of the palette.

type

A character string specifying the type of palettes to select from: "all", "seq" (sequential), "div" (diverging), or "qual" (qualitative). Default is "all".

colorblind

A logical value indicating whether to restrict the palette to colorblind-friendly options. Default is `FALSE`.

Value

A character vector of colors.

See also

'list_doypa_pals' to list available palettes. 'preview_doypa_pals' to preview all color palettes.

Examples

# Get a palette by name
colors <- doypa("buzz")
print(colors)
#> [1] "#6036a4" "#9de26b" "#F5C290" "#B1B3B3" "#FF2400" "#ADD8E6"

# Get a random palette
colors <- doypa()
#> Ready, set, color! We've gone with the 'doypa_qual' palette - no need to sweat it!
print(colors)
#> [1] "#bceecb" "#91debc" "#67cdac" "#42ba9b" "#7f9d3a" "#d47200" "#d64b02"
#> [8] "#ba2314" "#880024"

# Get a palette with a specific number of colors
colors <- doypa("google", n = 3)
print(colors)
#> [1] "#4285F4" "#34A853" "#FBBC05"

# Reverse the order of the palette
colors <- doypa("buzz", reverse = TRUE)
print(colors)
#> [1] "#ADD8E6" "#FF2400" "#B1B3B3" "#F5C290" "#9de26b" "#6036a4"

# Interpolate colors as a gradient
colors <- doypa("buzz", n = 10, gradient = TRUE)
#> Warning: 'n' larger than the palette length. Returning buzz palette with interpolated colors.
print(colors)
#>  [1] "#6036A4" "#819584" "#A6DE6F" "#D7CC83" "#E5BE97" "#C0B6AB" "#CA8377"
#>  [8] "#F63313" "#DA7366" "#ADD8E6"