Well…
Imagine that…
You are about to have your house built. Where do you start? By creating the plans, right?
Well, it’s the same with a {ggplot2}
graph. Start by building the
plans of your data visualization: its organization, its colours, etc. In
a familiar click-button environment (you will seen, Figma will do the
job very well).
Like an architect who guides you in extracting the ideas you have in
mind for the structure of your house and in transforming them into
technical concepts, {architekter}
will build for you the basis of your
theme()
function, by extracting the {ggplot2}
elements from your
Figma model. You can then modify your theme()
function directly in R.
But {architekter}
greatly prefers this work, especially if you are not
yet very familiar with the construction of {ggplot2}
themes.
“architekter” means “architect” in Breton, a regional language spoken in France. And that Brittany is one of the most beautiful places in the world.
Figma is a the collaborative interface design tool.
Figma is free.
More information here: https://www.figma.com/design/
You can install the development version of {architekter} from GitHub with:
# install.packages("devtools")
devtools::install_github("ThinkR-open/architekter")
-
Create a Figma account (https://www.figma.com)
-
Duplicate the following Figma file: https://www.figma.com/community/file/1089210046480653802 You we get a copy on your Figma account, and you will be able to modify your version to create your own {ggplot2} maquettes in Figma
-
Create a personal access token on your Figma account (https://www.figma.com/developers/api Section Access tokens)
-
Create an environment variable with your Figma Token:
Sys.setenv(FIGMA_TOKEN = "your-token-here")
-
Restart your R session
-
Load
{architekter}
library(architekter)
- Extract the {ggplot2} theme elements from your Figma file:
get_figma_file_content(file_key = "your-file-key",
acess_token = Sys.getenv("FIGMA_TOKEN")) %>%
extract_ggplot_theme()
get_figma_file_content(file_key = "wRqIvMmymzSPuj0sEhnORb",
acess_token = Sys.getenv("FIGMA_TOKEN")) %>%
extract_ggplot_theme()
#> ✓ Content of the file 'ggplot2 templating' has been successfully extracted.
#> ✓ The raw Figma content has been successfully transformed to a tibble.
#> ✓ The ggplot2 theme elements have been extracted.
#> # A tibble: 8 × 10
#> element_name element_type letter_spacing lineheight family size hjust color
#> <chr> <chr> <dbl> <dbl> <chr> <dbl> <dbl> <chr>
#> 1 panel_backgr… rect NA NA <NA> 0.400 NA #000…
#> 2 legend_text text 0.36 10.5 Roboto 9 1 #000…
#> 3 legend_title text 0.44 12.9 Roboto 11 1 #000…
#> 4 panel_grid line NA NA <NA> 1 NA #5FB…
#> 5 axis_text text 0 10.5 Roboto 9 1 #B0B…
#> 6 axis_title text 0.44 12.9 Roboto 11 1 #000…
#> 7 plot_subtitle text 0.48 14.1 Robot… 12 1 #000…
#> 8 plot_title text 0.8 23.4 Robot… 20 0 #000…
#> # … with 2 more variables: fill <chr>, linetype <dbl>