Learn R Programming

rPlotter (version 0.0.8)

mpd_select_colours: Select colours from a palette to maximize perceptual distance between the colours

Description

This function takes a palette as a character vector of hexidecimal colours, and returns a smaller palette, attempting to maximize the mean perceptual distance (MPD) between the colours in the new palette. It uses CIELAB colorspace to map colour to a perceptually meaningful scale before maximizing distances

Usage

mpd_select_colours(pal, sat.thresh = NULL, light.thresh = NULL, dark.thresh = NULL, nreps = 10000, ncolours = ceiling(length(pal)/2), nreturn = 1)

Arguments

pal
A palette as a character vector containing hexidecimal coded colours
sat.thresh
Minimum saturation of colours in resulting palette (between 0 and 1)
light.thresh
Maximum luminosity of colours in resulting palette (between 0 and 1)
dark.thresh
Minimum luminosity of colours in resulting palette (between 0 and 1)
nreps
The number of samples of the new colour palette to perform for brute force optimization of MPD
ncolours
The number of colours to select for the new palette
nreturn
The number of palettes to return

Value

If nreturn > 1 then a list of length nreturn, each element of which is a character vector of length ncolours consisting of hexidecimal colour codes, else a character vector of length ncolours consisting of hexidecimal colour codes