Description Usage Arguments Details Value Examples
multihue()
, multihue.diverge()
address the problem of creating multi-hue (multi "stop")
color scales with perceptually linear lightness gradients and smooth hue and chroma gradients
(with no first or second order discontinuities).
1 2 3 4 5 6 7 | multiHue(n = 11, colors = c("#081d58", "#086699", "#08BEC1", "#ffff66"))
multiHue.diverge(n = 11, lcolors = c("#0000d0", "#0479C8", "#08C8C8",
"#ffff00"), rcolors = c("#ffff00", "#FF9696", "#CD4949", "#800000"),
continuous = TRUE)
multiHue.constantL(n = 11, h = c(0, -45, -90, -135), c = 50, l = 60)
|
n |
Integer. Number of levels in palette (number of bins). Default: |
colors |
Character vector. (Only used with |
lcolors |
Character vector. (Only used with |
rcolors |
Character vector. (Only used with |
continuous |
Logical. (Default: TRUE) If continuous=TRUE (the default), A divergent palette
with no central discontinuity is created by joining |
h |
Numeric vector. (Only used with |
c |
Numeric vector. (Only used with |
l |
Numeric. (Only used with |
Pallettes produced by multihue()
, multihue.diverge()
and multihue.constantL()
use bezier
interpolation in HCL space to produce smooth, transient-free color scales. After interpolation,
the scales are stretched to correct any non-linearity in brightness gradient introduced by the
presence of intermediate color "stops." The result is a perceptually linear brightness gradient,
even when printed in black and white.
The palette is specified by a vector of colors (or two vectors in the case of
multihue.diverge
). The first and last colors of each vector are endpoints of a color scale,
and optional intermediate color "stops" are treated as control points for a bezier curve
connecting the endpoints in HCL colorspace. These intermediate color stops are therefore not
actually present in the final color palette, but influence it. Colors may defined as hex codes or
with hue, chroma and lightness values, as in grDevices::hcl()
.
These functions are built on top of Gregor Aisch's chroma.js javascript library. The functions access chroma.js javascript functions using the V8 package.
Palette characteristics:
perceptually linear brightness gradients
smooth hue gradient throughout (no "corners")
multiple color stops allow increased color discrimination between levels
hue and chroma gradients not necessarily linear. Only brightness is adjusted for linearity.
character vector. A vector of RGB colors specified as hex color codes (#RRGGBB).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | p <- multiHue()
colorbar(p)
## Maroon to yellow through salmon and pink
stops <- c('#800000', '#CD4949', '#FF9696','#FFFF00')
colorbar(stops) # display stops
palette <- multiHue(1024,colors=stops)
colorbar(palette) # display palette
## Divergent (default)
p <- multiHue.diverge(1024)
colorbar(p)
## Divergent with discontinuity: left = Blue to Cyan, right = Yellow to Red
leftstops <- c("#3136AA","#3980B0","#00C5C0","#8EFDFD")
colorbar(leftstops)
rightstops <- c("#F3F300","#FF8CB4","#CD4C4C","#8F0000")
colorbar(rightstops)
palette <- multiHue.diverge(1024,leftstops,rightstops,continuous=FALSE)
colorbar(palette)
## Constant Lightness (and chroma) color palette:
## 4 color stops define the bezier curve through HCL space; n=6 colors are output.
multiHue.constantL(n=6, h=c(-180, -105, -45, 0),c=50,l=60)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.