```{r}
#| label: params
### |- plot aesthetics ----
bkg_col <- colorspace::lighten('#f7f5e9', 0.05)
title_col <- "gray20"
subtitle_col <- "gray20"
caption_col <- "gray30"
text_col <- "gray20"
col_palette <- MoMAColors::moma.colors(palette_name = "Panton", n = 6, type = 'discrete')
### |- titles and caption ----
# icons
tt <- str_glue("#TidyTuesday: { 2024 } Week { 37 } • Source: Opportunity Insights: College-Level Data for 139 Selective American Colleges<br>")
li <- str_glue("<span style='font-family:fa6-brands'></span>")
gh <- str_glue("<span style='font-family:fa6-brands'></span>")
mn <- str_glue("<span style='font-family:fa6-brands'></span>")
# text
title_text <- str_glue("Distribution of College Attendance Rates by Selectivity Tier")
subtitle_text <- str_glue("A Comparison of Attendance Rates for U.S. Colleges Across Selectivity Levels")
caption_text <- str_glue("{tt} {li} stevenponce • {mn} @sponce1(graphic.social) {gh} poncest • #rstats #ggplot2")
### |- fonts ----
font_add("fa6-brands", "fonts/6.4.2/Font Awesome 6 Brands-Regular-400.otf")
font_add_google("Oswald", regular.wt = 400, family = "title")
font_add_google("Merriweather Sans", regular.wt = 400, family = "subtitle")
font_add_google("Merriweather Sans", regular.wt = 400, family = "text")
font_add_google("Noto Sans", regular.wt = 400, family = "caption")
showtext_auto(enable = TRUE)
### |- plot theme ----
theme_set(theme_minimal(base_size = 14, base_family = "text"))
theme_update(
plot.title.position = "plot",
plot.caption.position = "plot",
legend.position = 'plot',
plot.background = element_rect(fill = bkg_col, color = bkg_col),
panel.background = element_rect(fill = bkg_col, color = bkg_col),
plot.margin = margin(t = 10, r = 20, b = 10, l = 20),
axis.title.x = element_text(margin = margin(10, 0, 0, 0), size = rel(1.1),
color = text_col, family = "text", face = "bold", hjust = 0.5),
axis.title.y = element_text(margin = margin(0, 10, 0, 0), size = rel(1.1),
color = text_col, family = "text", face = "bold", hjust = 0.5),
axis.text = element_text(size = rel(0.8), color = text_col, family = "text"),
axis.line.x = element_line(color = "gray40", linewidth = .15),
panel.grid.minor.y = element_blank(),
panel.grid.major.y = element_line(linetype = "dotted", linewidth = 0.1, color = 'gray10'),
panel.grid.minor.x = element_blank(),
panel.grid.major.x = element_line(linetype = "dotted", linewidth = 0.1, color = 'gray10'),
strip.text = element_textbox(size = rel(0.9),
face = 'bold',
color = text_col,
hjust = 0.5,
halign = 0.5,
r = unit(3, "pt"),
width = unit(6, "npc"),
padding = margin(2, 0, 2, 0),
margin = margin(3, 3, 3, 3),
fill = "transparent"),
panel.spacing = unit(1, 'lines')
)
```