Examples for 'colorspace::desaturate'


Desaturate Colors by Chroma Removal in HCL Space

Aliases: desaturate

Keywords: color

### ** Examples

## rainbow of colors and their desaturated counterparts
rainbow_hcl(12)
 [1] "#E495A5" "#DB9D85" "#C7A76C" "#ABB065" "#86B875" "#5CBD92" "#39BEB1"
 [8] "#4CB9CC" "#7DB0DD" "#ACA4E2" "#CD99D8" "#E093C3"
desaturate(rainbow_hcl(12))
 [1] "#ABABAB" "#ABABAB" "#ABABAB" "#ABABAB" "#ABABAB" "#ABABAB" "#ABABAB"
 [8] "#ABABAB" "#ABABAB" "#ABABAB" "#ABABAB" "#ABABAB"
## 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)))
plot of chunk example-colorspace-desaturate-1
## apply desaturation directly on RGB values
RGB <- t(hex2RGB(rainbow(3))@coords * 255)
desaturate(RGB)
      [,1]     [,2]     [,3]
R 127.1223 219.9281 75.94690
G 127.1213 219.9264 75.94625
B 127.1266 219.9352 75.94962

[Package colorspace version 2.0-3 Index]