Learn R Programming

billboarder (version 0.5.2)

bb_bar_color_manual: Manual color for barchart

Description

Manual color for barchart

Usage

bb_bar_color_manual(bb, values)

Value

A `billboard` `htmlwidget` object.

Arguments

bb

A `billboard` `htmlwidget` object.

values

A named vector, names represent the categories of the bar chart, values correspond to colors. All categories must be present in the vector, in the same order of the chart.

Examples

Run this code
if (FALSE) {
library("data.table")
library("billboarder")

data("mpg", package = "ggplot2")
setDT(mpg)

# all in blue
manufa <- unique(mpg$manufacturer)
cols <- rep("#08298A", length(manufa))
names(cols) <- manufa

# Nissan in red
cols[["nissan"]] <- "#DF0101"

billboarder() %>%
  bb_barchart(data = mpg[, list(count = .N), by = manufacturer][order(count)]) %>%
  bb_bar_color_manual(values = cols)
}

Run the code above in your browser using DataLab