Code
# Data wrangling & visualization
library(tidyverse) # Data manipulation & visualization
# Spatial data handling
library(sf) # Import, export, and manipulate vector data
library(terra) # Import, export, and manipulate raster data
# ggplot2 extensions
library(tidyterra) # Helper functions for using terra with ggplot2
# Final plot tools
library(scales) # Nice Scales for ggplot2
library(fontawesome) # Icons display in ggplot2
library(ggtext) # Markdown text in ggplot2
library(showtext) # Display fonts in ggplot2
library(patchwork) # Composing Plots
bts = 42 # Base Text Size
sysfonts::font_add_google("Roboto Condensed", "body_font")
sysfonts::font_add_google("Oswald", "title_font")
sysfonts::font_add_google("Saira Extra Condensed", "caption_font")
showtext::showtext_auto()
# A base Colour
bg_col <- "white"
seecolor::print_color(bg_col)
# Colour for highlighted text
text_hil <- "grey30"
seecolor::print_color(text_hil)
# Colour for the text
text_col <- "grey20"
seecolor::print_color(text_col)
theme_set(
theme_minimal(
base_size = bts,
base_family = "body_font"
) +
theme(
text = element_text(
colour = "grey30",
lineheight = 0.3,
margin = margin(0,0,0,0, "pt")
),
plot.title = element_text(
hjust = 0.5
),
plot.subtitle = element_text(
hjust = 0.5
)
)
)
# Caption stuff for the plot
sysfonts::font_add(
family = "Font Awesome 6 Brands",
regular = here::here("docs", "Font Awesome 6 Brands-Regular-400.otf")
)
github <- ""
github_username <- "aditya-dahiya"
xtwitter <- ""
xtwitter_username <- "@adityadahiyaias"
social_caption_1 <- glue::glue("<span style='font-family:\"Font Awesome 6 Brands\";'>{github};</span> <span style='color: {text_hil}'>{github_username} </span>")
social_caption_2 <- glue::glue("<span style='font-family:\"Font Awesome 6 Brands\";'>{xtwitter};</span> <span style='color: {text_hil}'>{xtwitter_username}</span>")
plot_caption <- paste0(
"**Data**: Open Street Maps through {osmextract}",
" | **Code:** ",
social_caption_1,
" | **Graphics:** ",
social_caption_2
)
rm(github, github_username, xtwitter,
xtwitter_username, social_caption_1,
social_caption_2)




