Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

pal.maxdist

Measure the maximum distance between two palettes


Description

Measure the maximum distance between two palettes

Usage

pal.maxdist(pal1, pal2, n = 255)

Arguments

pal1

A color palette (function or vector)

pal2

A color palette (function or vector)

n

Number of colors to use, default 255

Details

The distance between two palettes (of equal length) is calculated pointwise using the Lab color space. A 'just noticeable difference' between colors is roughly 2.3.

Value

Numeric value of the maximum distance.

Author(s)

Kevin Wright

References

https://en.wikipedia.org/wiki/Color_difference

Examples

pa0 <- c("#ff0000","#00ff00","#0000ff")
pa1 <- c("#fa0000","#00fa00","#0000fa") # 2.4
pa2 <- c("#f40000","#00f400","#0000f4") # 5.2
pal.maxdist(pa0,pa1) # 2.36
pal.maxdist(pa0,pa2) # 5.20
pal.bands(pa1,pa0,pa2, labels=c("2.36","0","5.20"))
title("Maximum Lab distance from middle palette")

# distance between colormap functions
pal.maxdist(coolwarm,warmcool)

pals

Color Palettes, Colormaps, and Tools to Evaluate Them

v1.7
GPL-3
Authors
Kevin Wright [aut, cre] (<https://orcid.org/0000-0002-0617-8673>)
Initial release
2021-04-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.