{"spec_id":"voronoi-basic","library":"makie","language":"julia","code":"# anyplot.ai\n# voronoi-basic: Voronoi Diagram for Spatial Partitioning\n# Library: makie 0.21.9 | Julia 1.11.9\n# Quality: 90/100 | Created: 2026-09-02\n\nusing CairoMakie\nusing Random\n\nRandom.seed!(42)\n\n# Theme tokens (see prompts/default-style-guide.md \"Background\" + \"Theme-adaptive Chrome\")\nTHEME    = get(ENV, \"ANYPLOT_THEME\", \"light\")\nPAGE_BG  = THEME == \"light\" ? colorant\"#FAF8F1\" : colorant\"#1A1A17\"\nINK      = THEME == \"light\" ? colorant\"#1A1A17\" : colorant\"#F0EFE8\"\nINK_SOFT = THEME == \"light\" ? colorant\"#4A4A44\" : colorant\"#B8B7B0\"\n\n# Imprint sequential colormap (brand green -> blue) for continuous cell coloring\nimprint_seq = cgrad([colorant\"#009E73\", colorant\"#4467A3\"])\n\n# Data — retail store locations across a city grid, colored by daily foot traffic\nn_stores = 26\nstore_x = rand(n_stores) .* 12.0\nstore_y = rand(n_stores) .* 6.5\ndaily_visits = 300.0 .+ 1400.0 .* rand(n_stores)\n\n# Plot — see default-style-guide.md \"Visual Sizing Defaults\" for the canvas + sizing values\nfig = Figure(resolution = (1600, 900), fontsize = 14, backgroundcolor = PAGE_BG)\n\nax = Axis(\n    fig[1, 1];\n    title             = \"voronoi-basic · julia · makie · anyplot.ai\",\n    titlesize         = 29,\n    titlecolor        = INK,\n    xlabel            = \"X Position (km)\",\n    ylabel            = \"Y Position (km)\",\n    xlabelcolor       = INK,\n    ylabelcolor       = INK,\n    xticklabelcolor   = INK_SOFT,\n    yticklabelcolor   = INK_SOFT,\n    xtickformat       = xs -> string.(round.(xs, digits = 1)),\n    ytickformat       = ys -> string.(round.(ys, digits = 1)),\n    backgroundcolor   = PAGE_BG,\n    topspinevisible   = false,\n    rightspinevisible = false,\n    leftspinecolor    = INK_SOFT,\n    bottomspinecolor  = INK_SOFT,\n    aspect            = DataAspect(),\n)\n\n# Bounding box the Voronoi cells are clipped to, so unbounded edge regions never appear\nbbox = Rect2f(Point2f(-0.5, -0.5), Vec2f(13.0, 7.5))\n\nvp = voronoiplot!(\n    ax, store_x, store_y, daily_visits;\n    colormap    = imprint_seq,\n    colorrange  = (minimum(daily_visits), maximum(daily_visits)),\n    strokecolor = INK,\n    strokewidth = 1.5,\n    markercolor = INK,\n    markersize  = 17,\n    clip        = bbox,\n)\nxlims!(ax, -0.5, 12.5)\nylims!(ax, -0.5, 7.0)\n\n# Emphasize the busiest store — a focal highlight ring for data storytelling\ntop_idx = argmax(daily_visits)\nscatter!(\n    ax, [store_x[top_idx]], [store_y[top_idx]];\n    markersize  = 30,\n    color       = :transparent,\n    strokewidth = 2.5,\n    strokecolor = INK,\n)\n\n# Style\nColorbar(\n    fig[1, 2], vp;\n    label         = \"Daily Visits\",\n    labelcolor    = INK,\n    ticklabelcolor = INK_SOFT,\n    tickcolor     = INK_SOFT,\n    width         = 28,\n)\ncolgap!(fig.layout, 1, 15)\n\n# Save\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}