Voronoi Diagram for Spatial Partitioning — Makie.jl

A Voronoi diagram partitions a plane into regions based on the distance to a set of seed points, where each region contains all points closer to its seed than to any other. This visualization is essential for understanding spatial relationships, proximity analysis, and territorial boundaries. It reveals natural clustering patterns and helps identify areas of influence around data points.

Voronoi Diagram for Spatial Partitioning rendered with Makie.jl

Renders

Julia source (Makie.jl)

# anyplot.ai
# voronoi-basic: Voronoi Diagram for Spatial Partitioning
# Library: makie 0.21.9 | Julia 1.11.9
# Quality: 90/100 | Created: 2026-09-02

using CairoMakie
using Random

Random.seed!(42)

# Theme tokens (see prompts/default-style-guide.md "Background" + "Theme-adaptive Chrome")
THEME    = get(ENV, "ANYPLOT_THEME", "light")
PAGE_BG  = THEME == "light" ? colorant"#FAF8F1" : colorant"#1A1A17"
INK      = THEME == "light" ? colorant"#1A1A17" : colorant"#F0EFE8"
INK_SOFT = THEME == "light" ? colorant"#4A4A44" : colorant"#B8B7B0"

# Imprint sequential colormap (brand green -> blue) for continuous cell coloring
imprint_seq = cgrad([colorant"#009E73", colorant"#4467A3"])

# Data — retail store locations across a city grid, colored by daily foot traffic
n_stores = 26
store_x = rand(n_stores) .* 12.0
store_y = rand(n_stores) .* 6.5
daily_visits = 300.0 .+ 1400.0 .* rand(n_stores)

# Plot — see default-style-guide.md "Visual Sizing Defaults" for the canvas + sizing values
fig = Figure(resolution = (1600, 900), fontsize = 14, backgroundcolor = PAGE_BG)

ax = Axis(
    fig[1, 1];
    title             = "voronoi-basic · julia · makie · anyplot.ai",
    titlesize         = 29,
    titlecolor        = INK,
    xlabel            = "X Position (km)",
    ylabel            = "Y Position (km)",
    xlabelcolor       = INK,
    ylabelcolor       = INK,
    xticklabelcolor   = INK_SOFT,
    yticklabelcolor   = INK_SOFT,
    xtickformat       = xs -> string.(round.(xs, digits = 1)),
    ytickformat       = ys -> string.(round.(ys, digits = 1)),
    backgroundcolor   = PAGE_BG,
    topspinevisible   = false,
    rightspinevisible = false,
    leftspinecolor    = INK_SOFT,
    bottomspinecolor  = INK_SOFT,
    aspect            = DataAspect(),
)

# Bounding box the Voronoi cells are clipped to, so unbounded edge regions never appear
bbox = Rect2f(Point2f(-0.5, -0.5), Vec2f(13.0, 7.5))

vp = voronoiplot!(
    ax, store_x, store_y, daily_visits;
    colormap    = imprint_seq,
    colorrange  = (minimum(daily_visits), maximum(daily_visits)),
    strokecolor = INK,
    strokewidth = 1.5,
    markercolor = INK,
    markersize  = 17,
    clip        = bbox,
)
xlims!(ax, -0.5, 12.5)
ylims!(ax, -0.5, 7.0)

# Emphasize the busiest store — a focal highlight ring for data storytelling
top_idx = argmax(daily_visits)
scatter!(
    ax, [store_x[top_idx]], [store_y[top_idx]];
    markersize  = 30,
    color       = :transparent,
    strokewidth = 2.5,
    strokecolor = INK,
)

# Style
Colorbar(
    fig[1, 2], vp;
    label         = "Daily Visits",
    labelcolor    = INK,
    ticklabelcolor = INK_SOFT,
    tickcolor     = INK_SOFT,
    width         = 28,
)
colgap!(fig.layout, 1, 15)

# Save
save("plot-$(THEME).png", fig; px_per_unit = 2)

Retrieve this implementation

Runnable source as JSON, for any HTTP client: https://api.anyplot.ai/specs/voronoi-basic/makie/code. Any spec id and library id listed in llms-full.txt fit the same URL shape; every URL below is complete and callable.

{
  "spec_id": "voronoi-basic",
  "language": "julia",
  "library": "makie",
  "page": "https://anyplot.ai/voronoi-basic/julia/makie",
  "hub": "https://anyplot.ai/voronoi-basic",
  "code_json": "https://api.anyplot.ai/specs/voronoi-basic/makie/code",
  "spec_json": "https://api.anyplot.ai/specs/voronoi-basic",
  "render_light_png": "https://storage.googleapis.com/anyplot-images/plots/voronoi-basic/julia/makie/plot-light.png",
  "render_dark_png": "https://storage.googleapis.com/anyplot-images/plots/voronoi-basic/julia/makie/plot-dark.png",
  "quality_score": 90.0,
  "license": "MIT",
  "guide": "https://anyplot.ai/llms.txt"
}

Part of Voronoi Diagram for Spatial Partitioning on anyplot.ai.

Other implementations