Learn R Programming

Polychrome (version 1.2.3)

sortByHue: Sorting Palettes

Description

Functions to sort palettes; potentially useful for combining existing palettes to create new ones.

Usage

sortByHue(colorset)
sortByLuminance(colorset)

Arguments

colorset

a character vector containing hexadecimal color values.

Value

Returns a new color set (i.e., a palette, implemented as a character string containing the hex values of color), after sorting.

Details

These functions take a palette as input, sort it either by the hue or by the luminance, and return the result. One possibnle aplication would be to combine "dark" and "light" palettes to generate larger version of the RColorBrewer "Paired" palette.

Examples

Run this code
# NOT RUN {
D <- dark.colors(24)
L <- light.colors(24)
X <- sortByHue(c(D,L))
names(X) <- colorNames(X)
X <- X[!duplicated(names(X))]
swatch(X)
Y <- sortByLuminance(X)
swatch(Y)
# }

Run the code above in your browser using DataLab