Create a ggplot2 theme using explicit colors or by automatically extracting colors from a brand.yml file.
theme_brand_ggplot2(
brand = NULL,
background = NULL,
foreground = NULL,
accent = NULL,
...,
base_size = 11,
title_size = base_size * 1.2,
title_color = NULL,
line_color = NULL,
rect_fill = NULL,
text_color = NULL,
plot_background_fill = NULL,
panel_background_fill = NULL,
panel_grid_major_color = NULL,
panel_grid_minor_color = NULL,
axis_text_color = NULL,
plot_caption_color = NULL
)A ggplot2::theme() object.
One of:
NULL (default): Automatically detect and read a _brand.yml file
A path to a brand.yml file or directory containing _brand.yml
A brand object (as returned by read_brand_yml() or as_brand_yml())
FALSE: Don't use a brand file; explicit colors must be provided
The background color, defaults to brand.color.background.
If provided directly, this value can be a valid R color or the name of a
color in brand.color or brand.color.palette.
The foreground color, defaults to brand.color.foreground.
If provided directly, this value can be a valid R color or the name of a
color in brand.color or brand.color.palette.
The accent color, defaults to brand.color.primary or
brand.color.palette.accent. If provided directly, this value can be a
valid R color or the name of a color in brand.color or
brand.color.palette.
Reserved for future use.
Base font size in points. Used for the size property of
ggplot2::element_text() in the text theme element.
Title font size in points. Used for the size property of
ggplot2::element_text() in the title theme element. Defaults to
base_size * 1.2.
Color for the color property of
ggplot2::element_text() in the title theme element. Can be a valid R
color or the name of a color in brand.color or brand.color.palette. If
not provided, defaults to the foreground color.
Color for the color property of ggplot2::element_line()
in the line theme element. Can be a valid R color or the name of a color
in brand.color or brand.color.palette. If not provided, defaults to a
blend of foreground and background colors.
Fill color for the fill property of
ggplot2::element_rect() in the rect theme element. Can be a valid R
color or the name of a color in brand.color or brand.color.palette. If
not provided, defaults to the background color.
Color for the color property of ggplot2::element_text()
in the text theme element. Can be a valid R color or the name of a color
in brand.color or brand.color.palette. If not provided, defaults to a
blend of foreground and background colors.
Fill color for the fill property of
ggplot2::element_rect() in the plot.background theme element. Can be a
valid R color or the name of a color in brand.color or
brand.color.palette. If not provided, defaults to the background color.
Fill color for the fill property of
ggplot2::element_rect() in the panel.background theme element. Can be a
valid R color or the name of a color in brand.color or
brand.color.palette. If not provided, defaults to the background color.
Color for the color property of
ggplot2::element_line() in the panel.grid.major theme element. Can be a
valid R color or the name of a color in brand.color or
brand.color.palette. If not provided, defaults to a blend of foreground
and background colors.
Color for the color property of
ggplot2::element_line() in the panel.grid.minor theme element. Can be a
valid R color or the name of a color in brand.color or
brand.color.palette. If not provided, defaults to a blend of foreground
and background colors.
Color for the color property of
ggplot2::element_text() in the axis.text theme element. Can be a valid
R color or the name of a color in brand.color or brand.color.palette.
If not provided, defaults to a blend of foreground and background colors.
Color for the color property of
ggplot2::element_text() in the plot.caption theme element. Can be a
valid R color or the name of a color in brand.color or
brand.color.palette. If not provided, defaults to a blend of foreground
and background colors.
The theme_brand_* functions can be used in two ways:
With a brand.yml file: The theme_brand_* functions use
read_brand_yml() to automatically detect and use a _brand.yml file in
your current project. You can also explicitly pass a path to a brand.yml
file or a brand object (as returned by read_brand_yml() or created with
as_brand_yml()). When a brand is provided, the theme functions will
use the colors defined in the brand file automatically.
With explicit colors: You can directly provide colors to override the
default brand colors, or you can use brand = FALSE to ignore any project
_brand.yml files and only use the explicitly provided colors.
Other branded theming functions:
theme_brand_flextable(),
theme_brand_gt(),
theme_brand_plotly(),
theme_brand_thematic()
brand <- as_brand_yml('
color:
palette:
black: "#1A1A1A"
white: "#F9F9F9"
orange: "#FF6F20"
foreground: black
background: white
primary: orange')
library(ggplot2)
ggplot(diamonds, aes(carat, price)) +
geom_point() +
theme_brand_ggplot2(brand)
Run the code above in your browser using DataLab