Skip to contents

Builds a named vector for ggplot2::scale_fill_manual(values = ): the highlighted categories in one color, everything else in another. Red is reserved for this; it is not in the categorical palette.

Usage

maison_highlight(categories, highlight, color = "red", base = "plum")

Arguments

categories

The categories on the chart, as a vector or factor. Duplicates are dropped.

highlight

The category or categories to pick out.

color, base

Brand color names (see maison_colors) for the highlighted and the muted categories. base = "olive" gives a quieter context color than plum.

Value

A named character vector of hex codes, one per category.

Examples

maison_highlight(c("Acme", "Bolt", "Core"), "Acme")
#>      Acme      Bolt      Core 
#> "#C0292D" "#463752" "#463752" 
maison_highlight(c("Acme", "Bolt", "Core"), "Acme", base = "olive")
#>      Acme      Bolt      Core 
#> "#C0292D" "#807B6C" "#807B6C" 

library(ggplot2)
df <- data.frame(brand = c("Acme", "Bolt", "Core"), share = c(42, 31, 27))
ggplot(df, aes(brand, share, fill = brand)) +
  geom_col(show.legend = FALSE) +
  scale_fill_manual(values = maison_highlight(df$brand, "Acme")) +
  theme_maison(base_family = "sans")