```{r}
#| label: plot
### |- final plot ----
p <- ggplot() +
geom_dumbbell(
data = filtered_monarchs_marriages,
aes(x = king_age, xend = consort_age, y = pair_name),
size = 0.25,
color = 'gray50',
size_x = 3,
size_xend = 3,
dot_guide = FALSE
) +
# Plot kings' data
geom_point(
data = kings_data,
aes(x = king_age, y = pair_name, color = "King's Age"),
size = 3
) +
geom_text(
data = kings_data,
aes(x = king_age, y = pair_name, label = king_name, hjust = hjust),
size = 2.8,
color = col_palette[2],
fontface = 'bold',
nudge_x = -2
) +
# Plot consorts' data
geom_point(
data = consorts_data,
aes(x = consort_age, y = pair_name, color = "Consort's Age"),
size = 3
) +
geom_text(
data = consorts_data,
aes(x = consort_age, y = pair_name, label = consort_name, hjust = hjust),
size = 2.8,
color = col_palette[1],
fontface = 'bold',
nudge_x = -2
) +
# Scales
scale_x_continuous(
limits = c(-15,80),
labels = scales::label_number(suffix = " yrs"),
position = "top"
) +
scale_y_discrete() +
scale_color_manual(
name = "Legend:",
values = col_palette
) +
coord_cartesian(clip = 'off') +
# Labs
labs(
x = element_blank(),
y = element_blank(),
title = title_text,
subtitle = subtitle_text,
caption = caption_text
) +
# Theme
theme(
plot.title = element_markdown(
size = rel(2),
family = "title",
color = title_col,
face = "bold",
lineheight = 0.85,
margin = margin(t = 5, b = 5)
),
plot.subtitle = element_markdown(
size = rel(1.1),
family = "subtitle",
color = title_col,
lineheight = 1,
margin = margin(t = 5, b = 15)
),
plot.caption = element_markdown(
size = rel(.65),
family = "caption",
color = caption_col,
lineheight = 0.6,
hjust = 0,
halign = 0,
margin = margin(t = 10, b = 0)
)
)
```