Skip to contents

Overview

brandr is an R package designed to facilitate brand identity management using the brand.yml standard. It provides functions to consistently access and apply brand colors, typography, and other visual elements across your R projects.

Unlike Posit’s thematic package, brandr offers more refined control over brand assets.

If you find this project useful, please consider giving it a star!   GitHub repo stars

brandr is not affiliated with Posit or the developers of brand.yml.

Installation

You can install the released version of brandr from CRAN with:

And the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("danielvartan/brandr")

Usage

brandr is equipped with several functions to help you use your _brand.yml file, like:

Example:

library(brandr)
library(ggplot2)
library(palmerpenguins)

penguins |>
  ggplot(aes(x = flipper_length_mm, fill = species)) +
    geom_histogram(alpha = 0.5, position = "identity") +
    scale_fill_brand_d() +
    labs(
      x = "Flipper Length (mm)",
      y = "Frequency",
      fill = "Species"
    )

Click here to see the full list.

Configuration

Path to _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")

Brand Color Scales

To control the colors of each brand color scale, assign 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"))
)

Setting Brand Fonts/Typefaces

brandr does not support custom fonts directly. We recommend using Yixuan Qiu’s showtext R package to apply custom fonts or typefaces to your plots.

Below is an example showing how to use the Google Font Open Sans in all of your plots using ggplot2. This example assumes that the font files are located in a ttf folder within your project directory.

library(brandr)
library(ggplot2)
library(here)
library(sysfonts)
library(showtext)

font_paths(here("ttf"))

font_add(
  family = "open-sans",
  regular = here("ttf", "opensans-regular.ttf"),
  bold = here("ttf", "opensans-bold.ttf"),
  italic = here("ttf", "opensans-italic.ttf"),
  bolditalic = here("ttf", "opensans-bolditalic.ttf"),
  symbol = NULL
)

showtext_auto()

theme_set(
  theme(
    text = element_text(
      color = get_brand_color("black"),
      family = "open-sans",
      face = "plain"
    )
  )
)

License

Copyright (C) 2025 Daniel Vartanian

brandr is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with
this program. If not, see <https://www.gnu.org/licenses/>.

Contributing

Contributions are welcome! Whether you want to report bugs, suggest features, or improve the code or documentation, your input is highly valued. Please check the issues tab for existing issues or to open a new one.

You can also support the development of brandr by becoming a sponsor. Click here to make a donation. Please mention brandr in your donation message.

Acknowledgments

brandr is not affiliated with Posit or the developers of brand.yml.

brandr brand identity is based on brand.yml brand identity.