Map Values to Colors

# S4 method for ColorMapping
map_to_colors(object, x)

Arguments

object

A ColorMapping-class object.

x

Input values.

Details

It maps a vector of values to a vector of colors.

This function provides a uniform way for discrete and continuous color mapping.

Value

A vector of colors.

Examples

cm = ColorMapping(colors = c("A" = "red", "B" = "black")) map_to_colors(cm, sample(c("A", "B"), 10, replace = TRUE))
#> [1] "#FF0000FF" "#FF0000FF" "#000000FF" "#FF0000FF" "#FF0000FF" "#000000FF" #> [7] "#000000FF" "#000000FF" "#FF0000FF" "#000000FF"
require(circlize) col_fun = colorRamp2(c(0, 1), c("white", "red")) cm = ColorMapping(col_fun = col_fun) map_to_colors(cm, runif(10))
#> [1] "#FF220EFF" "#FF3118FF" "#FFD9CBFF" "#FFCDBCFF" "#FF3D21FF" "#FFB8A1FF" #> [7] "#FFBBA4FF" "#FF6B49FF" "#FF5837FF" "#FFC9B6FF"