{"spec_id":"polar-basic","library":"makie","language":"julia","code":"# anyplot.ai\n# polar-basic: Basic Polar Chart\n# Library: makie 0.21.9 | Julia 1.11.9\n# Quality: 90/100 | Updated: 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]\nconst BRAND = IMPRINT_PALETTE[1]  # Imprint palette position 1 — always first series\n\n# --- Data -----------------------------------------------------------------\n# Hourly household energy consumption (kWh) — a bimodal morning/evening pattern\nhour = 0:23\nmorning_peak = 1.2 .* exp.(-0.5 .* ((hour .- 7) ./ 1.5) .^ 2)\nevening_peak = 2.0 .* exp.(-0.5 .* ((hour .- 19) ./ 2.0) .^ 2)\nnoise = 0.12 .* randn(length(hour))\nconsumption = 0.8 .+ morning_peak .+ evening_peak .+ noise\n\ntheta = collect(hour) ./ 24 .* 2pi\ntheta_closed = vcat(theta, 2pi)              # wrap the last segment back to hour 0\nconsumption_closed = vcat(consumption, consumption[1])\n\n# --- Plot -------------------------------------------------------------------\nfig = Figure(size = (1200, 1200), backgroundcolor = PAGE_BG)\n\nax = PolarAxis(\n    fig[1, 1];\n    theta_0 = -pi / 2,                         # midnight at the top\n    direction = -1,                            # hours advance clockwise, like a clock face\n    title = \"polar-basic · julia · makie · anyplot.ai\",\n    titlesize = 20,\n    titlecolor = INK,\n    backgroundcolor = PAGE_BG,\n    thetaticks = (\n        0:(pi / 4):(7pi / 4),\n        [\"00:00\", \"03:00\", \"06:00\", \"09:00\", \"12:00\", \"15:00\", \"18:00\", \"21:00\"],\n    ),\n    thetaticklabelsize = 14,\n    thetaticklabelcolor = INK_SOFT,\n    rticks = 0:1:5,\n    rtickformat = values -> [\"$(v) kWh\" for v in values],\n    rtickangle = pi / 8,                       # offset from the 00:00 spoke to avoid label clash\n    rticklabelsize = 12,\n    rticklabelcolor = INK_SOFT,\n    spinecolor = INK_SOFT,\n    rgridcolor = RGBAf(INK.r, INK.g, INK.b, 0.15),\n    thetagridcolor = RGBAf(INK.r, INK.g, INK.b, 0.15),\n)\n\nband!(ax, theta_closed, zeros(length(theta_closed)), consumption_closed; color = (BRAND, 0.15))\nlines!(ax, theta_closed, consumption_closed; color = BRAND, linewidth = 3)\nscatter!(\n    ax, theta, consumption;\n    color = BRAND, markersize = 16, strokewidth = 1.5, strokecolor = PAGE_BG,\n)\n\n# --- Save -------------------------------------------------------------------\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}