value2color | R Documentation |
Get color values from a vector inside a regular interval
value2color(
var,
col = hcl.colors(41, "Blue-Red"),
interval = range(var),
n_classes = length(col),
alpha = NA,
beta = NA,
space = "HLS",
verbose = T
)
var |
numeric vector |
col |
colors |
interval |
range of values for the color interval (values outside the range are mapped in extremes) |
n_classes |
number of classes, see details |
alpha |
value or vector (0 to 1 range) to modify the alpha values |
beta |
value or vector (-1 to 1 range) to lighten the color values |
space |
one of "HCL", "HLS" or "combined" for colorspace::lighten |
verbose |
to display additional information |
the default number of classes (n_classes) is the number of colors (col) or length(var) - 1 if length(var) <= n_classes
x <- sin(pi/8 * 1:15)
barplot(x, col = value2color(x))
box()
barplot(x, col = value2color(x, alpha = seq(0,1,along.with=x)))
box()
barplot(x, col = value2color(x, beta = seq(0,1,along.with=x)))
box()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.