add_colors | R Documentation |
Add categorical colors to an existing color set
add_colors(
given_colors = NULL,
n = 1,
return_type = c("new", "full", "list"),
color_fn = rainbowJam,
check_internal = FALSE,
max_iterations = 50,
min_distance = 30,
step_distance = -1,
use_white = "F5",
method = "cie2000",
do_plot = FALSE,
verbose = FALSE,
seed = 123,
...
)
given_colors |
|
n |
|
return_type |
|
color_fn |
|
check_internal |
|
max_iterations |
|
min_distance |
|
step_distance |
|
use_white |
|
method |
|
do_plot |
|
verbose |
|
... |
additional arguments are passed to internal functions
|
character
vector of colors with length n
.
n1 <- 6;
n <- 2;
given <- jamba::nameVector(rainbowJam(n1));
new_colors <- add_colors(given, n=n, do_plot=TRUE, method="cmc")
names(new_colors) <- seq_along(new_colors);
show_color_distance(c(given, new_colors))
show_color_distance(c(given, new_colors), cluster_data=TRUE)
show_color_distance(sort_colors(c(given, new_colors)))
given2 <- c(given, new_colors);
color_pie(given2)
new_colors2 <- add_colors(unname(given2), n=n, do_plot=TRUE)
new_colors2 <- add_colors(unname(given2), n=n, do_plot=TRUE, dist_threshold=15)
new_colors2 <- add_colors(unname(given2), n=n, do_plot=TRUE, dist_threshold=20)
names(new_colors2) <- seq_along(new_colors2) + 2;
show_color_distance(sort_colors(c(given2, new_colors2)), cluster_data=TRUE)
jamba::showColors(list(
given=sort_colors(given),
`add 2`=sort_colors(c(given, new_colors)),
`add 2 more`=sort_colors(c(given2, new_colors2))))
new_colors4 <- add_colors(given, n=4, do_plot=TRUE, dist_threshold=20)
names(new_colors4) <- seq_along(new_colors4);
show_color_distance(sort_colors(c(given, new_colors4)))
jamba::showColors(list(given=given,
`add 2`=sort_colors(c(given, new_colors)),
`add 2 more`=sort_colors(c(given2, new_colors2)),
`add 4 upfront`=sort_colors(c(given, new_colors4))))
# Todo: consider ensuring desaturated colors are somewhat different also
show_color_distance(color_distance(given, new_colors), pc=c(given, new_colors))
hm1 <- show_color_distance(sort_colors(c(given, new_colors)), pc=unname(c(given, new_colors)))
hm1
hm2 <- show_color_distance(colorspace::desaturate(amount=0.7, sort_colors(c(given, new_colors))))
hm3 <- show_color_distance(colorspace::desaturate(amount=1, sort_colors(c(given, new_colors))))
hm1 + hm2 + hm3
# test commoon themes
given <- c(DM="dodgerblue3", CTL="gold")
add_colors(unname(given), n=3, do_plot=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.