huePal: Create (named) single-hue gradient palette

Description Usage Arguments Details Value Examples

View source: R/huePal.R

Description

Function to create create HCL palette of n colours based on fixed hue. Luminance monotonically increases, whilst chroma increases and then decreases.

If names provided: return named palette of same length as unique(names), with n distinct colours (if n is left null, all colours are unique)

If the hue value is left as NULL, a function will be returned, which can generate a palette when given a hue values and n and/or names

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
huePal(
  hue = NULL,
  names = NULL,
  n = NULL,
  minChroma = 40,
  maxChroma = 150,
  minLum = 10,
  maxLum = 98,
  power = 0.8
)

Arguments

hue

numeric hue value, or NULL to return palette function

names

names for palette, or NULL for unnamed palette of length n

n

number of unique shades in palette

minChroma

minimum Chroma for palette

maxChroma

maximum Chroma for palette

minLum

minimum luminance for palette

maxLum

maximum luminance for palette

power

power used by colorspace::sequential_hcl()

Details

Uses colorspace::sequential_hcl() with a fixed hue to generate palettes.

The palette generated will be roughly centered around the midpoint of the luminance range, and at approximately the maximum chroma.

Note that edges of generated palette are cut off so min and max luminances are never returned. This is because they are, by default, too dark/light to be distinguishable across hues.

Value

vector of colours, possibly named, or a function

Examples

1
2
3
4
5
6
7
pal <- huePal(hue = 120, n = 9)
scales::show_col(pal, borders = NA)
huePal(hue = 120, names = letters[1:9]) == huePal(hue = 120, n = 9)

# more names than shades --> repeats last shade
extendedPal <- huePal(hue = 120, names = letters[1:16], n = 9)
scales::show_col(extendedPal, borders = NA)

david-barnett/hueR documentation built on Dec. 19, 2021, 9:03 p.m.