# --- Hero: Ridgeline plot ------------------------------------------------
# Each ridge = one year; height = crane count; fill = year (Hokusai3 gradient)
p_ridge <- ggplot2::ggplot(
ridge_data,
ggplot2::aes(
x = day_of_year,
y = year_f,
height = obs / max(obs),
fill = year
)
) +
ggridges::geom_ridgeline(
scale = 5.5,
alpha = 0.88,
linewidth = 0.2,
color = "white"
) +
# Season separator lines
ggplot2::geom_vline(
xintercept = c(60, 152, 244, 305),
linetype = "dashed",
color = "grey60",
linewidth = 0.35,
alpha = 0.5
) +
# Season annotations (top of plot area, manual coordinates)
ggplot2::annotate(
"text", x = 100, y = 33.5, label = "Spring passage",
size = 3.2, color = "grey40", hjust = 0.5, fontface = "italic"
) +
ggplot2::annotate(
"text", x = 268, y = 33.5, label = "Fall passage",
size = 3.2, color = "grey40", hjust = 0.5, fontface = "italic"
) +
# 2023 fall record callout
ggplot2::annotate(
"segment",
x = 268, xend = 268, y = 1.5, yend = 3.2,
arrow = ggplot2::arrow(length = ggplot2::unit(0.12, "cm"), type = "closed"),
color = "#D8D97A", linewidth = 0.6
) +
ggplot2::annotate(
"text", x = 268, y = 3.5, label = "2023\nfall record",
size = 2.8, color = "#D8D97A", hjust = 0.5, fontface = "bold"
) +
ggplot2::scale_fill_gradientn(
colors = hokusai3_cols,
name = "Year"
) +
ggplot2::scale_x_continuous(
breaks = c(60, 91, 121, 152, 213, 244, 274, 305),
labels = c("Mar 1", "Apr 1", "May 1", "Jun 1", "Aug 1", "Sep 1", "Oct 1", "Nov 1"),
expand = c(0.01, 0)
) +
ggplot2::scale_y_discrete(expand = ggplot2::expansion(add = c(0.5, 2))) +
ggplot2::labs(
title = "Thirty Years of Cranes at Hornborgasjön",
subtitle = "Each ridge shows one year of crane counts (1994–2024).\nHeight reflects the number of birds observed on that day of the year.\nColor progresses from early years (yellow-green) to recent years (deep navy).",
x = NULL,
y = NULL,
caption = "Data: Hornborgasjön field station via TidyTuesday 2025-09-30 | Palette: MetBrewer::Hokusai3"
) +
ggplot2::theme_minimal(base_size = 11) +
ggplot2::theme(
plot.title = ggplot2::element_text(size = 18, face = "bold", margin = ggplot2::margin(b = 6)),
plot.subtitle = ggplot2::element_text(size = 10, color = "grey40", lineheight = 1.4,
margin = ggplot2::margin(b = 14)),
plot.caption = ggplot2::element_text(size = 7.5, color = "grey60", margin = ggplot2::margin(t = 10)),
axis.text.x = ggplot2::element_text(size = 8.5, color = "grey50"),
axis.text.y = ggplot2::element_text(size = 8, color = "grey50"),
panel.grid.major.x = ggplot2::element_blank(),
panel.grid.minor = ggplot2::element_blank(),
panel.grid.major.y = ggplot2::element_line(color = "grey92", linewidth = 0.3),
legend.position = "none",
plot.background = ggplot2::element_rect(fill = "white", color = NA),
plot.margin = ggplot2::margin(16, 20, 12, 16)
)
p_ridge