Skip to contents

This function returns a named vector of colors corresponding to the unique values in x. If the number of unique values is less than or equal to the length of main_colors, it selects the first n colors from main_colors. Otherwise, it generates a palette of n colors interpolated from main_colors.

Usage

get_color_palette(
  x,
  template = "inrae",
  main_colors = get_color_template(template, cfg),
  cfg = loadConfig()
)

Arguments

x

A vector of values for which a color palette is needed.

template

character The name of the theme template to apply.

main_colors

A character vector of color names or hex codes to use as the base palette.

cfg

a config object. Configuration to use. See loadConfig for details

Value

A named character vector of colors, with names corresponding to the unique values in x.

Examples

get_color_palette(c("A", "B", "C"), main_colors = c("red", "green", "blue"))
#>       A       B       C 
#>   "red" "green"  "blue" 
vec <- c("A", "B", "C", "D", "E", "F", "G", "H", "I")
palette <- get_color_palette(vec, template = "inrae")