voronoiplot
voronoiplot(x, y, values; kwargs...)
voronoiplot(values; kwargs...)
voronoiplot(x, y; kwargs...)
voronoiplot(positions; kwargs...)
voronoiplot(vorn::VoronoiTessellation; kwargs...)Generates and plots a Voronoi tessalation from heatmap- or point-like data. The tessellation can also be passed directly as a VoronoiTessellation from DelaunayTriangulation.jl.
Attributes
show_generators = truedetermines whether to plot the individual generators.markersize = 12sets the size of the points.marker = :circlesets the shape of the points.markercolor = :blacksets the color of the points.strokecolor = :blacksets the strokecolor of the polygons.strokewidth = 1sets the width of the polygon stroke.color = automaticsets the color of the polygons. Ifautomatic, the polygons will be individually colored according to the colormap.unbounded_edge_extension_factor = 0.1sets the extension factor for the unbounded edges, used inDelaunayTriangulation.polygon_bounds.clip::Union{Automatic, Rect2, Circle, Tuple} = automaticsets the clipping area for the generated polygons which can be aRect2(orBBox),Tuplewith entries(xmin, xmax, ymin, ymax)or as aCircle. Anything outside the specified area will be removed. If theclipis not set it is automatically determined usingunbounded_edge_extension_factoras aRect.
Color attributes
colormap::Union{Symbol, Vector{<:Colorant}} = :viridissets the colormap that is sampled for numericcolors.PlotUtils.cgrad(...),Makie.Reverse(any_colormap)can be used as well, or any symbol from ColorBrewer or PlotUtils. To see all available color gradients, you can callMakie.available_gradients().colorscale::Function = identitycolor transform function. Can be any function, but only works well together withColorbarforidentity,log,log2,log10,sqrt,logit,Makie.pseudolog10andMakie.Symlog10.colorrange::Tuple{<:Real, <:Real}sets the values representing the start and end points ofcolormap.nan_color::Union{Symbol, <:Colorant} = RGBAf(0,0,0,0)sets a replacement color forcolor = NaN.lowclip::Union{Nothing, Symbol, <:Colorant} = nothingsets a color for any value below the colorrange.highclip::Union{Nothing, Symbol, <:Colorant} = nothingsets a color for any value above the colorrange.alpha = 1.0sets the alpha value of the colormap or color attribute. Multiple alphas like inplot(alpha=0.2, color=(:red, 0.5), will get multiplied.
Examples
A voronoiplot generates a cell for each passed position similar to heatmap, however the cells are not restricted to a rectangular shape. It can be called with point based (like scatter or lines) or heatmap-like inputs.
using CairoMakie
using Random
Random.seed!(1234)
f = Figure(resolution=(1200, 450))
ax = Axis(f[1, 1])
voronoiplot!(ax, rand(Point2f, 50))
ax = Axis(f[1, 2])
voronoiplot!(ax, rand(10, 10), rand(10, 10), rand(10, 10))
fvoronoiplot uses the Voronoi tessellation from DelaunayTriangulation.jl to generate the cells. You can also do this yourself and directly plot the VoronoiTessellation object returned.
using CairoMakie
using DelaunayTriangulation
using Random
Random.seed!(1234)
points = rand(2, 50)
tri = triangulate(points)
vorn = voronoi(tri)
f, ax, tr = voronoiplot(vorn)
fWhen considering standard tessellations the unbounded polygons are clipped at a bounding box determined automatically by default, or from a user-provided clipping shape (a rectangle or circle). The automatic bounding box is determined by the bounding box of generators of the tessellation, meaning the provided points, extended out by some factor unbounded_edge_extension_factor (default 0.1) proportional to the lengths of the bounding box's sides.
using CairoMakie
using DelaunayTriangulation
using Random
Random.seed!(1234)
z = LinRange(0, 1, 250) .* exp.(LinRange(0, 16pi, 250) .* im)
f, ax, tr = voronoiplot(real(z), imag(z), unbounded_edge_extension_factor = 0.4, markersize = 7)
fusing CairoMakie
using DelaunayTriangulation
using Random
Random.seed!(1234)
x = LinRange(0, 16pi, 50)
y = sin.(x)
bb = BBox(-1, 16pi + 1, -30, 30) # (xmin, xmax, ymin, ymax)
f, ax, tr = voronoiplot(x, y, show_generators=false,
clip=bb, color=:white, strokewidth=2)
fFor clipped and centroidal tessellations, there are no unbounded polygons.
using CairoMakie
using DelaunayTriangulation
using Random
Random.seed!(1234)
points = [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)]
tri = triangulate(points)
refine!(tri; max_area = 0.001)
vorn = voronoi(tri, true)
f, ax, tr = voronoiplot(vorn, show_generators = true, markersize = 13, marker = 'x')
fusing CairoMakie
using DelaunayTriangulation
using Random
Random.seed!(1234)
angles = range(0, 2pi, length = 251)[1:end-1]
x = cos.(angles)
y = sin.(angles)
points = tuple.(x, y)
tri = triangulate(points)
refine!(tri; max_area = 0.001)
vorn = voronoi(tri, true)
smooth_vorn = centroidal_smooth(vorn)
f, ax, tr = voronoiplot(smooth_vorn, show_generators=false)
fThese docs were autogenerated using Makie: v0.19.12, GLMakie: v0.8.12, CairoMakie: v0.10.12, WGLMakie: v0.8.16