Skip to contents

Sometimes particular colours are coded in certain ways to facilitate interpretation. For example, perhaps primary colours or traffic light colours are used to represent some discrete options. Yet institutional palettes vary in terms of which colours they have available. This function uses the Euclidean distance of colours in CIELAB space to those of a target palette to find the closes corresponding colours.

Usage

match_color(colors, pal)

Arguments

colors

One or more hexcodes to match with colors from the palette.

pal

Optionally, a vector of hexcodes representing a palette in which to find matches. By default, the current theme's qualitative palette is used.

Value

A vector of hexcodes the length of the first argument.

Examples

match_color("#4575b4")
#> [1] "#4575B4"