Skip to contents

Manual color scale

Discrete color scale

Usage

v_scale_color_manual(vc, values)

v_scale_fill_manual(vc, values)

v_scale_color_discrete(vc, palette)

v_scale_fill_discrete(vc, palette)

Arguments

vc

An htmlwidget created with vchart() or specific chart's type function.

values

A named list with data values as name and color as values

palette

A color vector or the name of an R palette.

Value

A vchart() htmlwidget object.

A vchart() htmlwidget object.

Examples


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])