# --- Palette ---
# scico::lajolla — sequential from dark volcanic black through red to lava-yellow
# Thematically perfect for volcanic seismicity. Not previously used.
n_years <- length(unique(ridge_data$year))
year_colors <- paletteer::paletteer_c("scico::lajolla", n = n_years)
names(year_colors) <- as.character(sort(unique(ridge_data$year)))
# --- Plot A: Ridge plot of magnitude distributions by year ---
p_ridge <- ridge_data %>%
mutate(year_fct = fct_rev(year_fct)) %>% # recent year at top
ggplot2::ggplot(ggplot2::aes(
x = duration_magnitude_md,
y = year_fct,
fill = year_fct,
color = year_fct
)) +
ggridges::geom_density_ridges(
alpha = 0.80,
scale = 1.4,
linewidth = 0.3,
quantile_lines = TRUE,
quantiles = 2 # median line
) +
ggplot2::geom_vline(xintercept = 0, linetype = "dashed", color = "white", alpha = 0.7, linewidth = 0.6) +
ggplot2::geom_vline(xintercept = 2, linetype = "dotted", color = "white", alpha = 0.5, linewidth = 0.5) +
ggplot2::annotate("text", x = 0.07, y = 0.7, label = "Md = 0", color = "white",
size = 3, alpha = 0.8, hjust = 0, fontface = "italic") +
ggplot2::annotate("text", x = 2.07, y = 0.7, label = "Md = 2", color = "white",
size = 3, alpha = 0.8, hjust = 0, fontface = "italic") +
ggplot2::scale_fill_manual(values = rev(year_colors)) +
ggplot2::scale_color_manual(values = rev(year_colors)) +
ggplot2::scale_x_continuous(
limits = c(-2.5, 3.5),
breaks = seq(-2, 3, by = 1),
labels = function(x) paste0("Md ", x)
) +
ggplot2::labs(
x = "Duration Magnitude (Md)",
y = NULL,
subtitle = "Median magnitude shown as white line within each ridge"
) +
ggplot2::theme_minimal(base_size = 12) +
ggplot2::theme(
legend.position = "none",
plot.background = ggplot2::element_rect(fill = "#1a1008", color = NA),
panel.background = ggplot2::element_rect(fill = "#1a1008", color = NA),
panel.grid.major.x = ggplot2::element_line(color = "#3a2a18", linewidth = 0.3),
panel.grid.major.y = ggplot2::element_blank(),
panel.grid.minor = ggplot2::element_blank(),
axis.text = ggplot2::element_text(color = "#c8a882", size = 10),
axis.title.x = ggplot2::element_text(color = "#c8a882", size = 10, margin = ggplot2::margin(t = 8)),
plot.subtitle = ggplot2::element_text(color = "#8a6a45", size = 9, hjust = 0)
)
# --- Plot B: Annual event counts ---
p_bar <- annual_summary %>%
mutate(year_fct = factor(year)) %>%
ggplot2::ggplot(ggplot2::aes(x = year_fct, y = n_events, fill = year_fct)) +
ggplot2::geom_col(width = 0.75) +
ggplot2::geom_text(
ggplot2::aes(label = n_events),
vjust = -0.4, size = 3.2, color = "#c8a882"
) +
ggplot2::scale_fill_manual(values = year_colors) +
ggplot2::scale_y_continuous(expand = ggplot2::expansion(mult = c(0, 0.12))) +
ggplot2::labs(
x = NULL,
y = "Events recorded",
subtitle = "Annual seismic event count"
) +
ggplot2::theme_minimal(base_size = 12) +
ggplot2::theme(
legend.position = "none",
plot.background = ggplot2::element_rect(fill = "#1a1008", color = NA),
panel.background = ggplot2::element_rect(fill = "#1a1008", color = NA),
panel.grid.major.y = ggplot2::element_line(color = "#3a2a18", linewidth = 0.3),
panel.grid.major.x = ggplot2::element_blank(),
panel.grid.minor = ggplot2::element_blank(),
axis.text = ggplot2::element_text(color = "#c8a882", size = 10),
axis.title.y = ggplot2::element_text(color = "#c8a882", size = 10, margin = ggplot2::margin(r = 8)),
plot.subtitle = ggplot2::element_text(color = "#8a6a45", size = 9, hjust = 0)
)
# --- Combine with patchwork ---
p_combined <- p_bar / p_ridge +
patchwork::plot_layout(heights = c(1, 2)) +
patchwork::plot_annotation(
title = "The Restless Pulse of Vesuvius",
subtitle = "12,000+ seismic events recorded by INGV beneath Mount Vesuvius, 2013–2024.\nNearly all are microearthquakes (Md < 1) reflecting magmatic fluid movement, not impending eruption.",
caption = "Source: INGV / TidyTuesday 2025-05-13 · Palette: scico::lajolla",
theme = ggplot2::theme(
plot.background = ggplot2::element_rect(fill = "#1a1008", color = NA),
plot.title = ggtext::element_markdown(
color = "#f5d99a", size = 20, face = "bold",
margin = ggplot2::margin(b = 6)
),
plot.subtitle = ggplot2::element_text(
color = "#a07848", size = 11, lineheight = 1.4,
margin = ggplot2::margin(b = 12)
),
plot.caption = ggplot2::element_text(
color = "#6a4a28", size = 8,
margin = ggplot2::margin(t = 10)
),
plot.margin = ggplot2::margin(20, 24, 16, 24)
)
)
p_combined