Skip to contents

Apply brand colors to a plotly plot.

Usage

theme_brand_plotly(
  plot,
  brand = NULL,
  background = NULL,
  foreground = NULL,
  accent = NULL
)

Arguments

plot

A plotly plot object to theme.

brand

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

background

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.

foreground

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.

accent

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.

Value

Returns a themed plotly plot object.

See also

Examples

brand <- as_brand_yml('
color:
  palette:
    black: "#1A1A1A"
    white: "#F9F9F9"
    orange: "#FF6F20"
  foreground: black
  background: white
  primary: orange')

library(plotly)
#> 
#> Attaching package: ‘plotly’
#> The following object is masked from ‘package:ggplot2’:
#> 
#>     last_plot
#> The following objects are masked from ‘package:flextable’:
#> 
#>     highlight, style
#> The following object is masked from ‘package:stats’:
#> 
#>     filter
#> The following object is masked from ‘package:graphics’:
#> 
#>     layout
plot_ly(palmerpenguins::penguins, x = ~bill_length_mm, y = ~bill_depth_mm) |>
  theme_brand_plotly(brand)
if (FALSE) { # rlang::is_installed("plotly") && getRversion() < "4.5" brand <- as_brand_yml(' color: palette: black: "#1A1A1A" white: "#F9F9F9" orange: "#FF6F20" foreground: black background: white primary: orange') library(plotly) plot_ly(mtcars, x = ~wt, y = ~mpg) |> theme_brand_plotly(brand) }