Fonts, colors, and other design details

Author

Suparna Chaudhry and Andrew Heiss

Date

December 1, 2022

Modified

February 2, 2023

Code
library(tidyverse)
library(targets)
library(scales)

tar_config_set(store = here::here('_targets'),
               script = here::here('_targets.R'))

# Load graphics functions from targets
invisible(list2env(tar_read(graphic_functions), .GlobalEnv))

show_nice_pal <- function(pal, nrow = 1, show_text = TRUE) {
  out <- tibble(x = 1:length(pal),
                color = pal) %>% 
    mutate(x_nice = glue::glue("[{x}]")) %>% 
    mutate(across(c(color, x_nice), ~fct_inorder(.))) %>% 
    ggplot(aes(x = color, y = 1, fill = color)) +
    geom_tile() +
    scale_x_discrete(expand = c(0, 0)) +
    scale_fill_identity() +
    facet_wrap(vars(x_nice), scales = "free_x", nrow = nrow) +
    theme_void(base_family = "Inconsolata") +
    theme(panel.spacing.x = unit(-1, units = "pt"),
          panel.spacing.y = unit(-0.5, units = "lines"),
          strip.text = element_blank())
  
  if (show_text) {
    out <- out + 
      theme(axis.text.x = element_text(margin = margin(b = 5)),
            strip.text = element_text(size = rel(1.1), margin = margin(t = 5)),
            panel.spacing.y = unit(0, units = "lines"))
  }
  
  return(out)
}

Fonts

We use Inter (accessible for free from Google Fonts) as the main font in all our plots.

Inter

Whereas recognition of the inherent dignity and of the equal and inalienable rights of all members of the human family is the foundation of freedom, justice and peace in the world…

In the fancy preprint version of our manuscript we use Linux Libertine for the main body font, since it fits with Libertinus Math for fancier math typesetting.

Linux Libertine

Whereas recognition of the inherent dignity and of the equal and inalienable rights of all members of the human family is the foundation of freedom, justice and peace in the world…

Colors

Prism (clrs$Prism)

Our main palette is the qualitative Prism palette from CARTOColors. CARTOColors palettes were designed for data-focused map visualizations,but can be used in any kind of visualization, similar to ColorBrewer.

Access the palette using clrs$Prism, and access specific colors with indexes like clrs$Prism[8]:

Code
clrs$Prism %>% set_names(1:length(.))
##         1         2         3         4         5         6         7         8 
## "#5F4690" "#1D6996" "#38A6A5" "#0F8554" "#73AF48" "#EDAD08" "#E17C05" "#CC503E" 
##         9        10        11        12 
## "#94346E" "#6F4070" "#994E95" "#666666"

 

Single-ish-color sequential palettes

In some cases, like with plots that use geom_lineribbon(), we use a range of sequential colors. For these, we use several different sequential palettes from CARTOColors since they tend to match the color scheme from clrs$prism.

Emerald (clrs$Emrld)

Code
clrs$Emrld %>% set_names(1:length(.))
##         1         2         3         4         5         6         7 
## "#d3f2a3" "#97e196" "#6cc08b" "#4c9b82" "#217a79" "#105965" "#074050"

 

Purple orange (clrs$PurpOr)

Code
clrs$PurpOr %>% set_names(1:length(.))
##         1         2         3         4         5         6         7 
## "#f9ddda" "#f2b9c4" "#e597b9" "#ce78b3" "#ad5fad" "#834ba0" "#573b88"

 

Teal (clrs$Teal)

Code
clrs$Teal %>% set_names(1:length(.))
##         1         2         3         4         5         6         7 
## "#d1eeea" "#a8dbd9" "#85c4c9" "#68abb8" "#4f90a6" "#3b738f" "#2a5674"

 

Peach (clrs$Peach)

Code
clrs$Peach %>% set_names(1:length(.))
##         1         2         3         4         5         6         7 
## "#fde0c5" "#facba6" "#f8b58b" "#f59e72" "#f2855d" "#ef6a4c" "#eb4a40"

 

Sunset (clrs$Sunset)

Code
clrs$Sunset %>% set_names(1:length(.))
##         1         2         3         4         5         6         7 
## "#f3e79b" "#fac484" "#f8a07e" "#eb7f86" "#ce6693" "#a059a0" "#5c53a5"