{"spec_id":"band-basic","library":"makie","language":"julia","code":"# anyplot.ai\n# band-basic: Basic Band Plot\n# Library: makie 0.22.10 | Julia 1.11.9\n# Quality: 89/100 | Created: 2026-05-29\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 ELEVATED_BG = THEME == \"light\" ? colorant\"#FFFDF6\" : colorant\"#242420\"\nconst INK         = THEME == \"light\" ? colorant\"#1A1A17\" : colorant\"#F0EFE8\"\nconst INK_SOFT    = THEME == \"light\" ? colorant\"#4A4A44\" : colorant\"#B8B7B0\"\n\nconst IMPRINT_PALETTE = [\n    colorant\"#009E73\",  # 1 — brand green, ALWAYS first series (Imprint palette)\n    colorant\"#C475FD\",  # 2 — lavender\n    colorant\"#4467A3\",  # 3 — blue\n    colorant\"#BD8233\",  # 4 — ochre\n    colorant\"#AE3030\",  # 5 — matte red\n    colorant\"#2ABCCD\",  # 6 — cyan\n    colorant\"#954477\",  # 7 — rose\n    colorant\"#99B314\",  # 8 — lime\n]\n\n# Theme-adaptive band alpha: higher in dark mode for contrast\nconst BAND_ALPHA = THEME == \"light\" ? 0.25f0 : 0.35f0\n\n# Data — 60-day temperature forecast with widening 95% confidence interval\nn = 60\ndays = Float64.(1:n)\n\ny_center = 14.0 .+ 0.06 .* days .+ 3.0 .* sin.(2π .* days ./ 30)\nsigma = 0.5 .+ 0.05 .* days\ny_lower = y_center .- 1.96 .* sigma\ny_upper = y_center .+ 1.96 .* sigma\n\nhist_mean = 15.0\n\n# Plot\nfig = Figure(\n    size            = (1600, 900),\n    fontsize        = 14,\n    backgroundcolor = PAGE_BG,\n)\n\nax = Axis(\n    fig[1, 1];\n    title              = \"band-basic · julia · makie · anyplot.ai\",\n    titlesize          = 20,\n    titlecolor         = INK,\n    titlefont          = :bold,\n    xlabel             = \"Forecast Day\",\n    ylabel             = \"Temperature (°C)\",\n    xlabelsize         = 14,\n    ylabelsize         = 14,\n    xticklabelsize     = 12,\n    yticklabelsize     = 12,\n    xlabelcolor        = INK,\n    ylabelcolor        = INK,\n    xticklabelcolor    = INK_SOFT,\n    yticklabelcolor    = INK_SOFT,\n    xtickcolor         = INK_SOFT,\n    ytickcolor         = INK_SOFT,\n    backgroundcolor    = PAGE_BG,\n    topspinevisible    = false,\n    rightspinevisible  = false,\n    leftspinecolor     = INK_SOFT,\n    bottomspinecolor   = INK_SOFT,\n    xgridvisible       = false,\n    ygridcolor         = RGBAf(INK.r, INK.g, INK.b, 0.15f0),\n    xminorgridvisible  = false,\n    yminorgridvisible  = false,\n)\n\n# Historical mean reference — hlines! is idiomatic Makie for horizontal reference\nhlines!(ax, [hist_mean];\n    color     = (IMPRINT_PALETTE[3], 0.65),\n    linewidth = 1.5,\n    linestyle = :dash)\n\n# 95% confidence interval band (semi-transparent Imprint brand green)\nband!(ax, days, y_lower, y_upper;\n    color = (IMPRINT_PALETTE[1], BAND_ALPHA))\n\n# Central forecast line\nlines!(ax, days, y_center;\n    color     = IMPRINT_PALETTE[1],\n    linewidth = 2.5)\n\n# Makie bracket! annotation: shows CI width at forecast horizon (day 60)\nbracket_x = Float64(n + 3)\nci_label = \"±$(round(1.96 * sigma[end], digits=1))°C\"\nbracket!(ax, bracket_x, y_lower[end], bracket_x, y_upper[end];\n    text      = ci_label,\n    color     = INK_SOFT,\n    textcolor = INK_SOFT,\n    fontsize  = 11)\n\nxlims!(ax, 0, n + 16)\n\n# Legend\naxislegend(ax,\n    [PolyElement(color = (IMPRINT_PALETTE[1], BAND_ALPHA), strokewidth = 0),\n     LineElement(color = IMPRINT_PALETTE[1], linewidth = 2.5),\n     LineElement(color = (IMPRINT_PALETTE[3], 0.65), linewidth = 1.5, linestyle = :dash)],\n    [\"95% CI\", \"Forecast mean\", \"Historical mean ($(Int(hist_mean))°C)\"],\n    position         = :lt,\n    backgroundcolor  = ELEVATED_BG,\n    framecolor       = INK_SOFT,\n    labelcolor       = INK_SOFT,\n    labelsize        = 12,\n)\n\n# Save\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}