library(tidyverse)
library(gapminder)
library(geomtextpath)
library(ggborderline)
library(MetBrewer)
countries <- c("Norway", "Iraq", "Rwanda", "Afghanistan")
# Assistant font from Google
# https://fonts.google.com/specimen/Assistant
gapminder %>%
filter(country %in% countries) %>%
mutate(country = factor(country, levels = countries, ordered = TRUE)) %>%
ggplot(aes(x = year, y = lifeExp, color = country)) +
geom_line(data = gapminder, aes(group = country, color = NULL), size = 0.1, color = "grey70") +
geom_borderline(size = 1, bordersize = 1) +
geom_labelline(aes(label = country, hjust = country, fill = country),
linecolor = NA, size = 4, textcolour = "white",
family = "Assistant SemiBold") +
scale_hjust_discrete(range = c(0.05, 0.055)) +
scale_color_manual(values = met.brewer("Egypt", 4)) +
scale_fill_manual(values = met.brewer("Egypt", 4)) +
guides(color = "none", fill = "none") +
labs(x = NULL, y = "Life expectancy",
title = "Life expectancy over time",
subtitle = "Gaps around the intersections!!",
caption = "Source: The Gapminder Project") +
theme_minimal(base_family = "Assistant") +
theme(panel.grid.minor = element_blank(),
plot.title = element_text(family = "Assistant", face = "bold", size = rel(1.5)),
plot.caption = element_text(family = "Assistant ExtraLight", size = rel(0.7), hjust = 0,
margin = margin(t = 15)))
Created on 2022-07-21 by the reprex package (v2.0.1)