distinct_rgb_palette: Generate a distinct RGB color palette

View source: R/colors.R

distinct_rgb_paletteR Documentation

Generate a distinct RGB color palette

Description

This function uses kmeans() over the RGB colorspace to generate N distinct RGB colors.

Usage

distinct_rgb_palette(n, alpha = 1, ...)

Arguments

n

numeric. Number of colors to generate

alpha

numeric. Transparency level of the color palette (0-1). Default 1.0

...

arguments passed to kmeans()

Details

This function uses very inaccurate defaults for the kmeans() function in the interest of speed. It's usually not a problem if kmeans() does not converge (colors are distinct enough for most purposes). If you get warnings, or you don't like the colors produced, you can modify the default arguments to the kmeans() function by passing in additional arguments to .... For example, increasing iterations can be done by passing iter.max = 100. Changing the kmeans algorithm can be done by specifying algorithm = "MacQueen". Changing these arguments may eliminate warnings or produce more distinct colors.

Value

vector of distinct RGB colors


jcalendo/coriell documentation built on March 5, 2025, 5:42 a.m.