colorConversions | R Documentation |
Convert colors from and to RGB and HSL formats
col2rgb.2(col) col2hsl(col) hsl2col(hsl) rgb2col(rgb) rgb2hsl(rgb) hsl2rgb(hsl)
col |
a character vector with colors to convert (palette) |
hsl |
a numeric matrix with three or four rows (hue, saturation, luminosity and alpha) |
rgb |
a numeric matrix with three or four rows (red, green, blue and alpha) |
These functions convert between RGB and HSL color spaces, and character vectors which contain color names or hash-encoded RGB values ("#FFCC00").
All functions support an alpha channel. For example, unlike the grDevices::col2rgb, col2rgb.2 returns a matrix with four rows: three for R, G and B channels and one for the alpha channel.
col2rgb.2 and col2hsl return a four-row matrix. rgb2col and hsl2col return a character vector.
col2rgb.2
: Convert a character vector of color names
(palette) to a matrix with RGB values
col2hsl
: Convert a character vector of color names (palette) to a matrix with HSL values
hsl2col
: Convert hsl matrix (3 or 4 row) to character vector of color names
rgb2col
: Convert rgb matrix (3 or 4 row) to character vector of color names
rgb2hsl
: Convert a 3- or 4-row matrix of RGB(A) values to a matrix of HSL(A) values
hsl2rgb
: Convert a matrix of HSL values into a matrix of RGB values
modCol
, modhueCol
, darkenCol
, saturateCol
haze <- plotPals("haze") col2rgb(haze) col2hsl(haze)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.