Generate an i want hue color palette in R.
Use devtools to install:
devtools::install_github("hoesler/rwantshue")
library('rwantshue')
# create a color scheme object
scheme <- iwanthue() # get the iwanthue singleton
scheme <- iwanthue(seed = 42, force_init = TRUE) # recreate with a seed
# generate a new color palette (vector of hex values) with presets...
scheme$hex(10)
scheme$hex(10, color_space = hcl_presets$fluo)
# ... or make custom adjustments:
color_space <- list(
c(330, 360), # hue range [0,360]
c(0, 100), # chroma range [0,100]
c(0, 100)) # lightness range [0,100]
palette <- scheme$hex(
n = 8,
force_mode = FALSE,
quality = 50,
color_space = color_space)
# use it in a plot
plot(1:8, col = scheme$hex(8), pch = 16, cex = 10)
# You can also fetch a rgb matrix
scheme$rgb(8)