View source: R/color-palettes-and-spectra.R
adjust_sub_colors | R Documentation |
Creates a vector of colors based on sub grouping.
adjust_sub_colors(
input,
clrp,
clrp.adjust = NULL,
clr.bottom = "white",
offset = 1,
into = c("main", "sub"),
sep = "_",
alphabetically = TRUE
)
input |
Character vector of group names. |
clrp |
Character value. The color palette of choice.
Run (Ignored if |
clrp.adjust |
Named character vector or NULL. If character, it adjusts the colors that are used to represent the groups. Names of the input vector must refer to the group and the respective named element denotes the color with which to represent the group. |
clr.bottom |
Character value. The color up to which the sub panel for each sub grouping is created. |
offset |
Integer value. If 1, the default, the last sub group is mapped
to the color that comes directly before |
into |
Character vector of length two. A combination of 'main', 'sub'.
If |
sep |
Character value. Is used to cut the sub grouping
information from the variabel in |
alphabetically |
If |
Named character vector. Names are the groups. Values are the colors.
library(tidyverse)
library(confuns)
df <-
mutate(
.data = iris,
numbers = sample(1:3, size = nrow(iris), replace = T),
spec_sub = str_c(Species, numbers, sep = ".") %>% as.factor()
)
adjust_out <- adjust_sub_colors(input = df$spec_sub, clrp = "npg", sep = ".")
print(adjust_out)
ggplot(data = df, mapping = aes(x = Sepal.Width, y = Sepal.Length)) +
geom_point(mapping = aes(color = spec_sub), size = 4) +
scale_color_add_on(
clrp = "npg",
variable = df$spec_sub,
clrp.adjust = adjust_out
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.