apply_gg_colors: Apply brand colours to a ggplot object

View source: R/theme.R

apply_gg_colorsR Documentation

Apply brand colours to a ggplot object

Description

Uses the same resolve_colors() priority chain as the highcharter engine so both backends always produce identical colour assignments:

Usage

apply_gg_colors(p, colors = NULL, n_groups = NULL, group_levels = NULL)

Arguments

p

A ggplot object.

colors

Character vector, palette name string, or NULL.

n_groups

Integer. Number of groups in the data. Drives which palette rule fires. Passed from ggplot_engine().

group_levels

Character vector or NULL. Group level names in data order. Used to name the palette so ggplot2 matches colours to groups by name rather than alphabetical sort.

Details

  1. Explicit colors argument

  2. getOption("highdir.colors") session default

  3. Built-in rules: n==2 -> hdir2, n<=10 -> hdir[1:n], n>10 -> viridis

Value

The modified ggplot object.


highdir documentation built on July 31, 2026, 5:06 p.m.