dev/sandbox/colorize2.R

library(scales)

x <- sort(stats::runif(10, 1, 10))

pal <- col_bin(c("red", "blue"), 1:10)

show_col(pal(x))
show_col(colorize(x))



show_col(hc_theme_smpl()$colors)

pal <- col_bin("Greens", domain = 0:100)
show_col(pal(sort(stats::runif(10, 60, 100))))

# Exponential distribution, mapped continuously
show_col(col_numeric("Blues", domain = NULL)(sort(rexp(16))))

# Exponential distribution, mapped by interval
show_col(col_bin("Blues", domain = NULL, bins = 4)(sort(rexp(16))))
# Exponential distribution, mapped by quantile
show_col(col_quantile("Blues", domain = NULL)(sort(rexp(16))))

# Categorical data; by default, the values being colored span the gamut...
show_col(col_factor("RdYlBu", domain = NULL)(LETTERS[1:5]))
# ...unless the data is a factor, without droplevels...
show_col(col_factor("RdYlBu", domain = NULL)(factor(LETTERS[1:5], levels=LETTERS)))
# ...or the domain is stated explicitly.
show_col(col_factor("RdYlBu", levels = LETTERS)(LETTERS[1:5]))
jbkunst/highcharter documentation built on March 14, 2024, 12:52 a.m.