{"spec_id":"rose-basic","library":"makie","language":"julia","code":"# anyplot.ai\n# rose-basic: Basic Rose Chart\n# Library: makie 0.21.9 | Julia 1.11.9\n# Quality: 91/100 | Created: 2026-07-25\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 INK_SOFT = THEME == \"light\" ? colorant\"#4A4A44\" : colorant\"#B8B7B0\"\nconst IMPRINT_PALETTE = [\n    colorant\"#009E73\", colorant\"#C475FD\", colorant\"#4467A3\", colorant\"#BD8233\",\n    colorant\"#AE3030\", colorant\"#2ABCCD\", colorant\"#954477\", colorant\"#99B314\",\n]\n\n# --- Data ---------------------------------------------------------------\n# Monthly rainfall for a temperate coastal city — wetter autumn/winter,\n# drier summer, a natural 12-month cycle where the circular layout maps\n# directly onto the calendar.\nmonths = [\n    \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\",\n    \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\",\n]\nn_months = length(months)\nbase_rainfall_mm = [82, 68, 74, 58, 52, 41, 33, 38, 54, 71, 88, 95]\nrainfall_mm = base_rainfall_mm .+ randn(n_months) .* 4\n\n# --- Plot -----------------------------------------------------------------\nfig = Figure(\n    resolution      = (1200, 1200),\n    fontsize        = 14,\n    backgroundcolor = PAGE_BG,\n)\n\nax = PolarAxis(\n    fig[1, 1];\n    theta_0             = -pi / 2,  # January starts at 12 o'clock\n    direction           = -1,       # clockwise, matching calendar order\n    backgroundcolor     = PAGE_BG,\n    title               = \"Monthly Rainfall · rose-basic · julia · makie · anyplot.ai\",\n    titlesize           = 20,\n    titlecolor          = INK,\n    thetaticks          = (range(0, 2pi, length = n_months + 1)[1:n_months], months),\n    thetaticklabelsize  = 14,\n    thetaticklabelcolor = INK_SOFT,\n    thetagridvisible    = false,\n    rticks              = 0:20:100,\n    rtickformat         = vs -> [\"$(round(Int, v)) mm\" for v in vs],\n    rtickangle          = 13pi / 12,  # Jul–Aug gap — the driest wedges, keeps labels off the tall bars\n    rticklabelsize      = 15,\n    rticklabelcolor     = INK_SOFT,\n    rgridvisible        = true,\n    rgridcolor          = RGBAf(INK.r, INK.g, INK.b, 0.15),\n    rgridwidth          = 1,\n    spinecolor          = INK_SOFT,\n    spinewidth          = 1,\n    rlimits             = (0, 110),\n)\n\n# Equal-angle wedges, radius proportional to value — filled with `band!`\n# since it (unlike `poly!`) respects the PolarAxis per-vertex transform\n# and traces a true curved arc rather than a straight-edged rectangle.\n# Fill alpha is ramped by value (spec's \"varying saturation\" option) so the\n# wettest months read as the visual focal point; the peak/trough wedges also\n# get a heavier outline as an explicit callout for the seasonal story.\ntheta = range(0, 2pi, length = n_months + 1)[1:n_months]\nhalf_width = (2pi / n_months) * 0.9 / 2\nn_arc_samples = 40\nrmin, rmax = extrema(rainfall_mm)\npeak_idx, trough_idx = argmax(rainfall_mm), argmin(rainfall_mm)\n\nfor (i, (t, rv)) in enumerate(zip(theta, rainfall_mm))\n    ts = collect(range(t - half_width, t + half_width, length = n_arc_samples))\n    alpha = 0.55 + 0.45 * (rv - rmin) / (rmax - rmin)\n    wedge_color = RGBAf(IMPRINT_PALETTE[1].r, IMPRINT_PALETTE[1].g, IMPRINT_PALETTE[1].b, alpha)\n    band!(\n        ax, ts, zeros(n_arc_samples), fill(rv, n_arc_samples);\n        color = wedge_color,\n    )\n\n    if i == peak_idx || i == trough_idx\n        outline_theta = vcat(t - half_width, ts, t + half_width)\n        outline_r     = vcat(0.0, fill(rv, n_arc_samples), 0.0)\n        lines!(ax, outline_theta, outline_r; color = INK, linewidth = 2.5)\n    end\nend\n\n# --- Save -------------------------------------------------------------------\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}