knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(architekter)

Extract the {ggplot2} theme from a Figma file

You can use the extract_ggplot_theme() function to extract the elements of the {ggplot2} theme from a Figma file.

The Figma file is red with the get_figma_file_content() function. You can see the vignette b - Figma API connection and file extraction for more details.

get_figma_file_content(file_key = "wRqIvMmymzSPuj0sEhnORb",
                       acess_token = Sys.getenv("FIGMA_TOKEN")) %>% 
extract_ggplot_theme()

Details of the functions

Addition of the type of the {ggplot2} elements (i.e. rect, line or text)

corresp_element_type <- readr::read_rds(
  system.file("corresp_element_type.rds",
              package = "architekter"))
corresp_element_type %>% 
  head() %>% 
  knitr::kable()
data(toy_raw_file_content)

data_design <- toy_raw_file_content %>% 
  raw_to_design_tibble()

data_design %>% 
  add_ggplot_theme_type()

Determination of the {ggplot2} theme elements

data(toy_raw_file_content)

toy_raw_file_content %>% 
  raw_to_design_tibble() %>% 
  add_ggplot_theme_type() %>% 
  determine_ggplot_theme_elements()

Extract the {ggplot2} theme elements from a Figma file

data(toy_raw_file_content)

toy_raw_file_content %>% 
  extract_ggplot_theme()


ThinkR-open/swatch documentation built on April 7, 2022, 6:08 p.m.