| Title: | Brand Identity Management Using brand.yml Standard |
|---|---|
| Description: | A system to facilitate brand identity management using the brand.yml standard, providing functions to consistently access and apply brand colors, typography, and other visual elements across your R projects. |
| Authors: | Daniel Vartanian [aut, cre, ccp, cph] (ORCID: <https://orcid.org/0000-0001-7782-759X>) |
| Maintainer: | Daniel Vartanian <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.0.9000 |
| Built: | 2026-06-03 11:22:02 UTC |
| Source: | https://github.com/danielvartan/brandr |
color_brand_* functions are wrappers of
interpolate_colors() for sequential, diverging,
and qualitative brand color palettes. They serve as facilitators for
getting the colors being used in each brand scale.
color_brand_sequential(n, alpha = NULL, direction = 1) color_brand_diverging(n, alpha = NULL, direction = 1) color_brand_qualitative(n, alpha = NULL, direction = 1)color_brand_sequential(n, alpha = NULL, direction = 1) color_brand_diverging(n, alpha = NULL, direction = 1) color_brand_qualitative(n, alpha = NULL, direction = 1)
n |
This parameter accepts two types of inputs:
|
alpha |
(Optional) A number between |
direction |
(Optional) A number ( |
_brand.yml
brandr will always look for a _brand.yml file in the root directory of
your project. If the file is not found, an error message will be displayed.
You can also set the path to the file manually using the
options() function:
options(BRANDR_BRAND_YML = "PATH_TO_BRAND.YML")
To control the colors for each brand color scale, assign the desired
hexadecimal color codes in a
character vector to the following options:
BRANDR_COLOR_SEQUENTIAL: For sequential color scales
BRANDR_COLOR_DIVERGING: For diverging color scales
BRANDR_COLOR_QUALITATIVE: For qualitative color scales
You can use get_brand_color() to get the hexadecimal
color codes from the _brand.yml file.
Example:
options(
BRANDR_COLOR_SEQUENTIAL =
get_brand_color(c("primary", "secondary")),
BRANDR_COLOR_DIVERGING =
get_brand_color(c("primary", "white", "secondary")),
BRANDR_COLOR_QUALITATIVE =
get_brand_color(c("primary", "secondary", "tertiary"))
)
A character vector with
hexadecimal color codes.
Other color functions:
interpolate_colors()
color_brand_sequential(5) #> [1] "#390963" "#892B4F" "#DA4E3C" "#EA7220" "#FB9706" # Expected color_brand_diverging(5) #> [1] "#390963" "#9C84B1" "#FFFFFF" "#FDCB82" "#FB9706" # Expected color_brand_qualitative(5) #> [1] "#DA4E3C" "#390963" "#FB9706" "#DA4E3C" "#390963" # Expected color_brand_qualitative(3, alpha = 0.5) #> [1] "#DA4E3C80" "#39096380" "#FB970680" # Expectedcolor_brand_sequential(5) #> [1] "#390963" "#892B4F" "#DA4E3C" "#EA7220" "#FB9706" # Expected color_brand_diverging(5) #> [1] "#390963" "#9C84B1" "#FFFFFF" "#FDCB82" "#FB9706" # Expected color_brand_qualitative(5) #> [1] "#DA4E3C" "#390963" "#FB9706" "#DA4E3C" "#390963" # Expected color_brand_qualitative(3, alpha = 0.5) #> [1] "#DA4E3C80" "#39096380" "#FB970680" # Expected
get_brand_color() retrieves color codes from the _brand.yml file.
get_brand_color(color, alpha = NULL)get_brand_color(color, alpha = NULL)
color |
A |
alpha |
(Optional) A number between |
_brand.yml
brandr will always look for a _brand.yml file in the root directory of
your project. If the file is not found, an error message will be displayed.
You can also set the path to the file manually using the
options() function:
options(BRANDR_BRAND_YML = "PATH_TO_BRAND.YML")
A character vector with
hexadecimal color codes.
Other utility functions:
get_brand_color_mix(),
get_brand_color_tint(),
get_brand_font()
get_brand_color("primary") #> [1] "#DA4E3C" # Expected get_brand_color("secondary") #> [1] "#390963" # Expected get_brand_color("tertiary") #> [1] "#FB9706" # Expected get_brand_color("tertiary", alpha = 0.5) #> [1] "#FB970680" # Expected get_brand_color(c("primary", "secondary")) #> [1] "#DA4E3C" "#390963" # Expected get_brand_color(c("red", "purple", "orange")) #> [1] "#DA4E3C" "#390963" "#F06F20" # Expectedget_brand_color("primary") #> [1] "#DA4E3C" # Expected get_brand_color("secondary") #> [1] "#390963" # Expected get_brand_color("tertiary") #> [1] "#FB9706" # Expected get_brand_color("tertiary", alpha = 0.5) #> [1] "#FB970680" # Expected get_brand_color(c("primary", "secondary")) #> [1] "#DA4E3C" "#390963" # Expected get_brand_color(c("red", "purple", "orange")) #> [1] "#DA4E3C" "#390963" "#F06F20" # Expected
get_brand_color_mix() mixes two specific brand colors.
get_brand_color_mix( position = 500, color_1 = "primary", color_2 = "secondary", alpha = 0.5 )get_brand_color_mix( position = 500, color_1 = "primary", color_2 = "secondary", alpha = 0.5 )
position |
(Optional) A |
color_1, color_2
|
(Optional) A |
alpha |
(Optional) A number between |
_brand.yml
brandr will always look for a _brand.yml file in the root directory of
your project. If the file is not found, an error message will be displayed.
You can also set the path to the file manually using the
options() function:
options(BRANDR_BRAND_YML = "PATH_TO_BRAND.YML")
A character vector with
hexadecimal color codes.
Other utility functions:
get_brand_color(),
get_brand_color_tint(),
get_brand_font()
get_brand_color_mix( position = 500, color_1 = "primary", color_2 = "secondary", alpha = 0.5 ) #> [1] "#8A2C50" # Expected get_brand_color_mix( position = c(250, 500, 750), color_1 = "primary", color_2 = "secondary", alpha = 0.25 ) #> [1] "#591E23" "#B23D46" "#D89EA2" # Expectedget_brand_color_mix( position = 500, color_1 = "primary", color_2 = "secondary", alpha = 0.5 ) #> [1] "#8A2C50" # Expected get_brand_color_mix( position = c(250, 500, 750), color_1 = "primary", color_2 = "secondary", alpha = 0.25 ) #> [1] "#591E23" "#B23D46" "#D89EA2" # Expected
get_brand_color_tint() generates a range of tints (color variations) for a
specific brand color, from black (position 0) through the brand color
(position 500) to white (position 1000).
get_brand_color_tint(position = 500, color = "primary")get_brand_color_tint(position = 500, color = "primary")
position |
(Optional) A |
color |
(Optional) A |
_brand.yml
brandr will always look for a _brand.yml file in the root directory of
your project. If the file is not found, an error message will be displayed.
You can also set the path to the file manually using the
options() function:
options(BRANDR_BRAND_YML = "PATH_TO_BRAND.YML")
A character vector with
hexadecimal color codes.
Other utility functions:
get_brand_color(),
get_brand_color_mix(),
get_brand_font()
seq(0, 1000, 250) #> [1] 0 250 500 750 1000 # Expected get_brand_color_tint(seq(0, 1000, 250), color = "primary") #> [1] "#000000" "#6D271E" "#DA4E3C" "#ECA69D" "#FFFFFF" # Expectedseq(0, 1000, 250) #> [1] 0 250 500 750 1000 # Expected get_brand_color_tint(seq(0, 1000, 250), color = "primary") #> [1] "#000000" "#6D271E" "#DA4E3C" "#ECA69D" "#FFFFFF" # Expected
get_brand_font() retrieves the names of fonts/typefaces in the
_brand.yml file.
get_brand_font(font)get_brand_font(font)
font |
A |
_brand.yml
brandr will always look for a _brand.yml file in the root directory of
your project. If the file is not found, an error message will be displayed.
You can also set the path to the file manually using the
options() function:
options(BRANDR_BRAND_YML = "PATH_TO_BRAND.YML")
A character vector with fonts/typeface names.
Other utility functions:
get_brand_color(),
get_brand_color_mix(),
get_brand_color_tint()
get_brand_font("base") #> [1] "Open Sans" # Expected get_brand_font("headings") #> [1] "Rubik" # Expected get_brand_font("monospace") #> [1] "IBM Plex Mono" # Expected get_brand_font("monospace-block") #> [1] "IBM Plex Mono" # Expected get_brand_font(c("base", "headings")) #> [1] "Open Sans" "Rubik" # Expectedget_brand_font("base") #> [1] "Open Sans" # Expected get_brand_font("headings") #> [1] "Rubik" # Expected get_brand_font("monospace") #> [1] "IBM Plex Mono" # Expected get_brand_font("monospace-block") #> [1] "IBM Plex Mono" # Expected get_brand_font(c("base", "headings")) #> [1] "Open Sans" "Rubik" # Expected
interpolate_colors() interpolate colors for sequential, diverging,
and qualitative color scales.
interpolate_colors( n, colors = getOption("BRANDR_COLOR_SEQUENTIAL"), type = "seq", alpha = NULL, direction = 1, ... )interpolate_colors( n, colors = getOption("BRANDR_COLOR_SEQUENTIAL"), type = "seq", alpha = NULL, direction = 1, ... )
n |
This parameter accepts two types of inputs:
|
colors |
(Optional) A |
type |
(Optional) A |
alpha |
(Optional) A number between |
direction |
(Optional) A number ( |
... |
Additional arguments passed to
|
A character vector with
hexadecimal color codes.
Other color functions:
color_brand_sequential()
interpolate_colors(3, colors = c("red", "blue"), type = "seq") #> [1] "#FF0000" "#7F007F" "#0000FF" # Expected interpolate_colors(3, colors = c("red", "blue"), direction = -1) #> [1] "#0000FF" "#7F007F" "#FF0000" # Expected interpolate_colors(3, colors = c("red", "blue"), alpha = 0.5) #> [1] "#FF000080" "#7F007F80" "#0000FF80" # Expected # `type = "seq"` and `type = "div"` produce the same result interpolate_colors(3, colors = c("red", "white", "blue"), type = "div") #> [1] "#FF0000" "#FFFFFF" "#0000FF" # Expected interpolate_colors(3, colors = c("red", "blue"), type = "qual") #> [1] "#FF0000" "#0000FF" "#FF0000" # Expectedinterpolate_colors(3, colors = c("red", "blue"), type = "seq") #> [1] "#FF0000" "#7F007F" "#0000FF" # Expected interpolate_colors(3, colors = c("red", "blue"), direction = -1) #> [1] "#0000FF" "#7F007F" "#FF0000" # Expected interpolate_colors(3, colors = c("red", "blue"), alpha = 0.5) #> [1] "#FF000080" "#7F007F80" "#0000FF80" # Expected # `type = "seq"` and `type = "div"` produce the same result interpolate_colors(3, colors = c("red", "white", "blue"), type = "div") #> [1] "#FF0000" "#FFFFFF" "#0000FF" # Expected interpolate_colors(3, colors = c("red", "blue"), type = "qual") #> [1] "#FF0000" "#0000FF" "#FF0000" # Expected
ggplot2
scale_*_brand_*() functions provide color scales for
ggplot2 based on brand colors defined
in the _brand.yml file. These functions create discrete, continuous, or
binned scales with sequential, diverging, or qualitative color palettes
that match your brand identity.
scale_brand( aesthetics = "color", scale_type = "c", color_type = "seq", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... ) scale_color_brand_d( aesthetics = "color", scale_type = "d", color_type = "qual", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... ) scale_color_brand_c( aesthetics = "color", scale_type = "c", color_type = "seq", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... ) scale_color_brand_b( aesthetics = "color", scale_type = "b", color_type = "seq", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... ) scale_colour_brand_d( aesthetics = "color", scale_type = "d", color_type = "qual", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... ) scale_colour_brand_c( aesthetics = "color", scale_type = "c", color_type = "seq", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... ) scale_colour_brand_b( aesthetics = "color", scale_type = "b", color_type = "seq", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... ) scale_fill_brand_d( aesthetics = "fill", scale_type = "d", color_type = "qual", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... ) scale_fill_brand_c( aesthetics = "fill", scale_type = "c", color_type = "seq", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... ) scale_fill_brand_b( aesthetics = "fill", scale_type = "b", color_type = "seq", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... )scale_brand( aesthetics = "color", scale_type = "c", color_type = "seq", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... ) scale_color_brand_d( aesthetics = "color", scale_type = "d", color_type = "qual", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... ) scale_color_brand_c( aesthetics = "color", scale_type = "c", color_type = "seq", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... ) scale_color_brand_b( aesthetics = "color", scale_type = "b", color_type = "seq", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... ) scale_colour_brand_d( aesthetics = "color", scale_type = "d", color_type = "qual", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... ) scale_colour_brand_c( aesthetics = "color", scale_type = "c", color_type = "seq", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... ) scale_colour_brand_b( aesthetics = "color", scale_type = "b", color_type = "seq", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... ) scale_fill_brand_d( aesthetics = "fill", scale_type = "d", color_type = "qual", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... ) scale_fill_brand_c( aesthetics = "fill", scale_type = "c", color_type = "seq", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... ) scale_fill_brand_b( aesthetics = "fill", scale_type = "b", color_type = "seq", alpha = NULL, direction = 1, na.value = NA, reverse = FALSE, ... )
aesthetics |
(Optional) A |
scale_type |
(Optional) A |
color_type |
(Optional) A |
alpha |
(Optional) A number between |
direction |
(Optional) A number ( |
na.value |
(Optional) A |
reverse |
(Optional) A |
... |
Additional arguments passed to the |
_brand.yml
brandr will always look for a _brand.yml file in the root directory of
your project. If the file is not found, an error message will be displayed.
You can also set the path to the file manually using the
options() function:
options(BRANDR_BRAND_YML = "PATH_TO_BRAND.YML")
To control the colors for each brand color scale, assign the desired
hexadecimal color codes in a
character vector to the following options:
BRANDR_COLOR_SEQUENTIAL: For sequential color scales
BRANDR_COLOR_DIVERGING: For diverging color scales
BRANDR_COLOR_QUALITATIVE: For qualitative color scales
You can use get_brand_color() to get the hexadecimal
color codes from the _brand.yml file.
Example:
options(
BRANDR_COLOR_SEQUENTIAL =
get_brand_color(c("primary", "secondary")),
BRANDR_COLOR_DIVERGING =
get_brand_color(c("primary", "white", "secondary")),
BRANDR_COLOR_QUALITATIVE =
get_brand_color(c("primary", "secondary", "tertiary"))
)
A ggplot2 scale object.
if (requireNamespace( c("palmerpenguins", "tidyr", "ggplot2"), quiet = TRUE ) ) { library(ggplot2) library(palmerpenguins) library(tidyr) penguins |> drop_na(bill_length_mm, species) |> ggplot(aes(x = species, y = bill_length_mm, fill = species)) + geom_boxplot(outlier.color = get_brand_color("red")) + geom_jitter(width = 0.2, alpha = 0.1) + scale_fill_brand_d(alpha = 0.5) + labs( x = "Species", y = "Bill Length (mm)", fill = "Species" ) + theme_bw() } if (requireNamespace( c("palmerpenguins", "tidyr", "ggplot2"), quiet = TRUE ) ) { library(ggplot2) library(palmerpenguins) library(tidyr) penguins |> drop_na(flipper_length_mm, species) |> ggplot(aes(x = flipper_length_mm, fill = species)) + geom_histogram(alpha = 0.5, bins = 30, position = "identity") + scale_fill_brand_d() + labs( x = "Flipper Length (mm)", y = "Frequency", fill = "Species" ) + theme_bw() } if (requireNamespace( c("palmerpenguins", "tidyr", "ggplot2"), quiet = TRUE ) ) { library(ggplot2) library(palmerpenguins) library(tidyr) penguins |> drop_na(flipper_length_mm, body_mass_g, species) |> ggplot( aes( x = flipper_length_mm, y = body_mass_g, color = species, shape = species ) ) + geom_point(size = 2) + geom_smooth(method = "lm", formula = y ~ x, se = FALSE) + scale_color_brand_d() + labs( x = "Flipper Length (mm)", y = "Body Mass (g)", color = "Species", shape = "Species" ) + theme_bw() } if (requireNamespace("ggplot2", quiet = TRUE)) { library(ggplot2) faithfuld |> ggplot(aes(waiting, eruptions, fill = density)) + geom_raster() + scale_fill_brand_b() + labs( x = "Waiting Time to Next Eruption (min)", y = "Eruption Time (min)", fill = "Density" ) + theme_bw() } if (requireNamespace("ggplot2", quiet = TRUE)) { library(ggplot2) library(hexbin) data.frame(x = runif(10000), y = runif(10000)) |> ggplot(aes(x, y)) + geom_hex() + coord_fixed() + scale_fill_brand_c() + labs(fill = "") + theme_bw() }if (requireNamespace( c("palmerpenguins", "tidyr", "ggplot2"), quiet = TRUE ) ) { library(ggplot2) library(palmerpenguins) library(tidyr) penguins |> drop_na(bill_length_mm, species) |> ggplot(aes(x = species, y = bill_length_mm, fill = species)) + geom_boxplot(outlier.color = get_brand_color("red")) + geom_jitter(width = 0.2, alpha = 0.1) + scale_fill_brand_d(alpha = 0.5) + labs( x = "Species", y = "Bill Length (mm)", fill = "Species" ) + theme_bw() } if (requireNamespace( c("palmerpenguins", "tidyr", "ggplot2"), quiet = TRUE ) ) { library(ggplot2) library(palmerpenguins) library(tidyr) penguins |> drop_na(flipper_length_mm, species) |> ggplot(aes(x = flipper_length_mm, fill = species)) + geom_histogram(alpha = 0.5, bins = 30, position = "identity") + scale_fill_brand_d() + labs( x = "Flipper Length (mm)", y = "Frequency", fill = "Species" ) + theme_bw() } if (requireNamespace( c("palmerpenguins", "tidyr", "ggplot2"), quiet = TRUE ) ) { library(ggplot2) library(palmerpenguins) library(tidyr) penguins |> drop_na(flipper_length_mm, body_mass_g, species) |> ggplot( aes( x = flipper_length_mm, y = body_mass_g, color = species, shape = species ) ) + geom_point(size = 2) + geom_smooth(method = "lm", formula = y ~ x, se = FALSE) + scale_color_brand_d() + labs( x = "Flipper Length (mm)", y = "Body Mass (g)", color = "Species", shape = "Species" ) + theme_bw() } if (requireNamespace("ggplot2", quiet = TRUE)) { library(ggplot2) faithfuld |> ggplot(aes(waiting, eruptions, fill = density)) + geom_raster() + scale_fill_brand_b() + labs( x = "Waiting Time to Next Eruption (min)", y = "Eruption Time (min)", fill = "Density" ) + theme_bw() } if (requireNamespace("ggplot2", quiet = TRUE)) { library(ggplot2) library(hexbin) data.frame(x = runif(10000), y = runif(10000)) |> ggplot(aes(x, y)) + geom_hex() + coord_fixed() + scale_fill_brand_c() + labs(fill = "") + theme_bw() }