getColorFun | R Documentation |
Retrieve a color function mapping values to colors. Uses and modeled after circlize::colorRamp2
.
getColorFun(x, colPal = NULL)
x |
vector or matrix including potential values |
colPal |
a color palette to be used. Should be a character vector specifying colors. can be named if specific colors should be used for specific values |
a function mapping a value to a corresponding color character string
Fabian Mueller
randomLetters <- sample(letters[1:6], 50, replace=TRUE)
cf_cat <- getColorFun(randomLetters)
cf_cat("f")
cf_cat("x") # NA
cf_cat2 <- getColorFun(randomLetters, colPal=c(a="#009FE3", b="#DE7E00", c="#8EC041", d="#FFCC00", e="#951B81", f="#BE1716"))
cf_num <- getColorFun(runif(50))
cf_num2 <- getColorFun(runif(50), colpal.cont(9, "cb.YlOrRd")))
cf_num2(0.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.