Returns a vector of hex color values for a specified color palette.

palettes(index = NULL, type = "colorblind", plot = FALSE)

Arguments

index

An optional vector of integers or color names to extract a subset of colors from the specified palette.

type

The color palette to return. Options include...

  • 'Colorblind' (a colorblind-friendly palette);

  • 'Grayscale' (4-bit grayscale palette).

plot

Logical; if TRUE, generates a plot showcasing the specified color palette.

Value

A character vector of hex color values for the specified palette.

Examples

# List of possible inputs to argument
# 'type' for each palette
palettes()
#>     orange light blue        red      green       pink       blue     yellow 
#>  "#E69F00"  "#56B4E9"  "#D55E00"  "#009E73"  "#CC79A7"  "#0072B2"  "#F0E442" 

# Plot of colors in each palette
palettes("Colorblind", plot = TRUE)
#> <NA> 
#>   NA 
palettes("Grayscale", plot = TRUE)

#> <NA> 
#>   NA 

# Example of taking subset of colors
palettes("Colorblind", 1:2)
#> Error in if (type %in% types$colorblind) {    list_of_colors <- c(orange = "#E69F00", `light blue` = "#56B4E9",         red = "#D55E00", green = "#009E73", pink = "#CC79A7",         blue = "#0072B2", yellow = "#F0E442")}: the condition has length > 1