Set ggplot2 Theme from Brand Configuration
brand_set_ggplot.Rd
Sets the ggplot2 theme based on colors and typography defined in a _brand.yml file. This function reads the brand configuration and applies it as the default ggplot2 theme.
Details
This function reads a brand.yml file and extracts color and typography information to create a custom ggplot2 theme. The function:
Maps brand colors to ggplot2 theme elements
Attempts to load Google Fonts specified in the brand file
Stores the previous theme for later restoration
Sets the new theme as the default for all subsequent ggplot2 plots
The brand.yml file should follow the schema defined at: https://github.com/posit-dev/brand-yml/
Examples
if (FALSE) { # \dontrun{
# Set theme from default _brand.yml file
brand_set_ggplot()
# Create a plot - will use the brand theme
library(ggplot2)
ggplot(mtcars, aes(x = mpg, y = wt)) +
geom_point() +
labs(title = "Example Plot with Brand Theme")
# Reset to original theme
brand_reset_ggplot()
} # }