A simple util function that scales a factor to color based on the palette function.

mapcol(value, palette.fun = grDevices::rainbow, ...)

Arguments

value

A factor or character vector that may have n unique values.

palette.fun

The palette function to generate colors. For example, terrain.colors.

...

Extra arguments passed to the palette function.

Value

A character vector as colors, with the same length of value. Same values in value will have the same color.

Examples

mapcol(iris$Species)
#> [1] "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" #> [7] "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" #> [13] "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" #> [19] "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" #> [25] "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" #> [31] "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" #> [37] "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" #> [43] "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" "#FF0000FF" #> [49] "#FF0000FF" "#FF0000FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" #> [55] "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" #> [61] "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" #> [67] "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" #> [73] "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" #> [79] "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" #> [85] "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" #> [91] "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" #> [97] "#00FF00FF" "#00FF00FF" "#00FF00FF" "#00FF00FF" "#0000FFFF" "#0000FFFF" #> [103] "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" #> [109] "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" #> [115] "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" #> [121] "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" #> [127] "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" #> [133] "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" #> [139] "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" #> [145] "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF" "#0000FFFF"