{"spec_id":"heatmap-stripes-climate","library":"ggplot2","language":"r","code":"#' anyplot.ai\n#' heatmap-stripes-climate: Climate Warming Stripes\n#' Library: ggplot2 3.5.1 | R 4.4.1\n#' Quality: 90/100 | Created: 2026-06-02\n\nlibrary(ggplot2)\nlibrary(ragg)\n\nset.seed(42)\n\n# Theme tokens\nTHEME       <- Sys.getenv(\"ANYPLOT_THEME\", \"light\")\nPAGE_BG     <- if (THEME == \"light\") \"#FAF8F1\" else \"#1A1A17\"\nINK         <- if (THEME == \"light\") \"#1A1A17\" else \"#F0EFE8\"\n\n# Data - synthetic global temperature anomalies 1880-2024 (relative to 1961-1990 baseline)\nyears   <- 1880:2024\nn       <- length(years)\ntrend   <- (years - 1880) / (2024 - 1880) * 1.2\nnoise   <- rnorm(n, 0, 0.12)\ndip     <- ifelse(years >= 1945 & years <= 1975, -0.12, 0)\nanomaly <- trend + noise + dip\nanomaly <- anomaly - mean(anomaly[years >= 1961 & years <= 1990])\n\ndf <- data.frame(year = years, anomaly = anomaly)\n\n# Imprint diverging colormap: Imprint blue (cold) -> page neutral -> Imprint red (warm)\nMID_COLOR <- if (THEME == \"light\") \"#FAF8F1\" else \"#1A1A17\"\n\n# Title: 50 chars — below the 67-char baseline, no font-size scaling needed\ntitle_text <- \"heatmap-stripes-climate · r · ggplot2 · anyplot.ai\"\n\n# Warming stripes: one full-height bar per year, no axes, no labels, no grid\np <- ggplot(df, aes(x = year, y = 1, fill = anomaly)) +\n    geom_tile(width = 1, height = 2) +\n    scale_fill_gradient2(\n        low      = \"#4467A3\",  # Imprint blue  — cold anomaly\n        mid      = MID_COLOR,\n        high     = \"#AE3030\",  # Imprint red   — warm anomaly\n        midpoint = 0,\n        guide    = \"none\"\n    ) +\n    scale_x_continuous(expand = c(0, 0)) +\n    scale_y_continuous(limits = c(0, 2), expand = c(0, 0)) +\n    labs(title = title_text) +\n    theme_void() +\n    theme(\n        plot.background = element_rect(fill = PAGE_BG, color = NA),\n        plot.title      = element_text(\n            color  = INK,\n            size   = 12,\n            hjust  = 0.5,\n            margin = margin(b = 8)\n        ),\n        plot.margin = margin(t = 20, r = 20, b = 20, l = 20)\n    )\n\n# Save\nggsave(\n    filename = sprintf(\"plot-%s.png\", THEME),\n    plot     = p,\n    device   = ragg::agg_png,\n    width    = 8,\n    height   = 4.5,\n    units    = \"in\",\n    dpi      = 400\n)\n"}