scale-color-manual | R Documentation |
Manual color scale
Discrete color scale
v_scale_color_manual(vc, values)
v_scale_fill_manual(vc, values)
v_scale_color_discrete(vc, palette)
v_scale_fill_discrete(vc, palette)
vc |
An htmlwidget created with |
values |
A named list with data values as name and color as values |
palette |
A color vector or the name of an R palette. |
A vchart()
htmlwidget
object.
A vchart()
htmlwidget
object.
library(vchartr)
subset(electricity_mix, country %in% c("France", "Canada")) %>%
vchart() %>%
v_bar(aes(country, generation, fill = source)) %>%
v_scale_fill_manual(c(
"oil" = "#80549f",
"coal" = "#a68832",
"solar" = "#d66b0d",
"gas" = "#f20809",
"wind" = "#72cbb7",
"hydro" = "#2672b0",
"nuclear" = "#e4a701"
))
vchart(palmerpenguins::penguins) %>%
v_scatter(
aes(x = flipper_length_mm, y = body_mass_g, color = species)
) %>%
v_scale_color_manual(c(
Adelie = "#ffa232",
Chinstrap = "#33a2a2",
Gentoo = "#b34df2"
))
library(vchartr)
subset(electricity_mix, country %in% c("France", "Canada")) %>%
vchart() %>%
v_bar(aes(country, generation, fill = source)) %>%
v_scale_fill_discrete("Okabe-Ito")
subset(electricity_mix, country %in% c("France", "Canada")) %>%
vchart() %>%
v_bar(aes(country, generation, fill = source)) %>%
v_scale_fill_discrete("ggplot2")
# or
subset(electricity_mix, country %in% c("France", "Canada")) %>%
vchart() %>%
v_bar(aes(country, generation, fill = source)) %>%
v_scale_fill_discrete(palette.colors(palette = "ggplot2")[-1])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.