{"spec_id":"heatmap-stripes-climate","library":"makie","language":"julia","code":"# anyplot.ai\n# heatmap-stripes-climate: Climate Warming Stripes\n# Library: makie 0.22.10 | Julia 1.11.9\n# Quality: 90/100 | Created: 2026-06-02\n\nusing CairoMakie\nusing Colors\nusing Random\n\nRandom.seed!(42)\n\n# Theme tokens\nconst THEME   = get(ENV, \"ANYPLOT_THEME\", \"light\")\nconst PAGE_BG = THEME == \"light\" ? colorant\"#FAF8F1\" : colorant\"#1A1A17\"\nconst INK     = THEME == \"light\" ? colorant\"#1A1A17\" : colorant\"#F0EFE8\"\nconst TITLE   = \"heatmap-stripes-climate · julia · makie · anyplot.ai\"\n\n# Imprint diverging colormap: Imprint blue (cold) → neutral → Imprint red (warm)\n# Midpoint must contrast against background so near-zero anomaly stripes are visible\nconst div_mid     = THEME == \"light\" ? colorant\"#BDBBB4\" : colorant\"#6B6A63\"\nconst ANYPLOT_DIV = cgrad([colorant\"#4467A3\", div_mid, colorant\"#AE3030\"])\n\n# Data: simulated global temperature anomalies 1850–2023\nconst n_years = 174\nt           = range(0.0, 1.0; length=n_years)\ntrend       = -0.50 .+ 1.20 .* t .^ 2.0\nvariability = 0.12 .* randn(n_years)\nfor idx in [22, 41, 63, 91, 141]\n    variability[idx] -= 0.25\n    idx + 1 <= n_years && (variability[idx + 1] -= 0.08)\nend\nanomalies = trend .+ variability\nmax_abs   = max(abs(minimum(anomalies)), abs(maximum(anomalies)))\n\n# Figure: landscape 1600×900 × px_per_unit=2 → 3200×1800 px output\nfig = Figure(\n    size            = (1600, 900),\n    backgroundcolor = PAGE_BG,\n)\n\n# Stripes axis — no decorations, no spines\nax = Axis(\n    fig[1, 1];\n    backgroundcolor = PAGE_BG,\n)\nhidedecorations!(ax)\nhidespines!(ax)\n\n# Warming stripes: one vertical stripe per year (n_years × 1 heatmap)\nz = reshape(anomalies, n_years, 1)\nheatmap!(ax, 1:n_years, 1:1, z;\n    colormap   = ANYPLOT_DIV,\n    colorrange = (-max_abs, max_abs),\n)\nxlims!(ax, 0.5, n_years + 0.5)\nylims!(ax, 0.5, 1.5)\n\n# Mandated anyplot title (52 chars — no font scaling needed)\nLabel(fig[2, 1], TITLE;\n    fontsize  = 26,\n    color     = INK,\n    tellwidth = false,\n    padding   = (0, 0, 10, 6),\n)\n\nrowsize!(fig.layout, 1, Relative(0.88))\n\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}