distant_colors: Palettes of dissimilar colors in RGB space.

View source: R/functions.R

distant_colorsR Documentation

Palettes of dissimilar colors in RGB space.

Description

Many standard palette generators use only a slice of color space, which can cause a lack of differentiability in palettes used to visualize categorical factors with many levels. This function attempts to overcome this by generating colors using nearest-neighbor distance maximization in 3D RGB space.

Usage

distant_colors(
  n,
  res = 20,
  maxreps = 1000,
  radius = 10,
  avoid_white = TRUE,
  seed = NULL
)

Arguments

n

Number of colors (integer).

res

Number of distinct values in each RGB dimension (integer).

maxreps

Max number of optimization iterations (integer).

radius

Neighborhood size for potential moves, analagous to heating.

avoid_white

Logical, default is TRUE.

seed

Integer used to seed randomization during search; leave as NULL to generate different results each time, or set a value to generate reproducible results.

Value

Character vector of colors.

Examples

plot(runif(20), runif(20), 
     col = distant_colors(20), 
     pch = 16, cex = 3)

matthewkling/colormap documentation built on Nov. 4, 2023, 10:44 p.m.