map_to_colors-ColorMapping-method.Rd
Map Values to Colors
# S4 method for ColorMapping map_to_colors(object, x)
object | A |
---|---|
x | Input values. |
It maps a vector of values to a vector of colors.
This function provides a uniform way for discrete and continuous color mapping.
A vector of colors.
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"