R: Desaturate Colors by Chroma Removal in HCL Space

desaturate {colorspace} | R Documentation

## Desaturate Colors by Chroma Removal in HCL Space

### Description

Transform a vector of given colors to the corresponding colors with chroma removed (collapsed to zero) in HCL space.

### Usage

    desaturate(col)

### Arguments

`col` | vector of any of the three kind of R colors, i.e., either a color name (an element of `colors`), a hexadecimal string of the form `"#rrggbb"` or `"#rrggbbaa"` (see `rgb`), or an integer `i` meaning `palette()[i]`.

### Details

Given colors are first transformed to RGB (either using `hex2RGB` or `col2rgb`) and then to HCL (`polarLUV`). In HCL, chroma is removed (i.e., collapsed to zero) and then the color is transformed back to a hexadecimal string.

### Value

A character vector with (s)RGB codings of the colors in the palette.

### Author(s)

Achim Zeileis

### See Also

`polarLUV`, `hex`

### Examples

    ## rainbow of colors and their desaturated counterparts
    rainbow_hcl(12)
    desaturate(rainbow_hcl(12))

    ## convenience demo function
    wheel <- function(col, radius = 1, ...)
      pie(rep(1, length(col)), col = col, radius = radius, ...)

    ## compare base and colorspace palettes
    ## (in color and desaturated)
    par(mar = rep(0, 4), mfrow = c(2, 2))
    ## rainbow color wheel
    wheel(rainbow_hcl(12))
    wheel(rainbow(12))
    wheel(desaturate(rainbow_hcl(12)))
    wheel(desaturate(rainbow(12)))

[Package colorspace version 1.3-2 Index]