value2color: Get color values from a vector inside a regular interval

View source: R/value_color.R

value2colorR Documentation

Get color values from a vector inside a regular interval

Description

Get color values from a vector inside a regular interval

Usage

value2color(
  var,
  col = hcl.colors(41, "Blue-Red"),
  interval = range(var),
  n_classes = length(col),
  alpha = NA,
  beta = NA,
  space = "HLS",
  verbose = T
)

Arguments

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

Details

the default number of classes (n_classes) is the number of colors (col) or length(var) - 1 if length(var) <= n_classes

Examples

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()


Schuch666/hackWRF documentation built on June 9, 2025, 1:46 p.m.