Learn R Programming

autograph (version 0.1.2)

match_color: Matching colors across palettes

Description

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)

Value

A vector of hexcodes the length of the first argument.

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.

Examples

Run this code
match_color("#4575b4")

Run the code above in your browser using DataLab