poly

poly(vertices, indices; kwargs...)
poly(points; kwargs...)
poly(shape; kwargs...)
poly(mesh; kwargs...)

Plots a polygon based on the arguments given. When vertices and indices are given, it functions similarly to mesh. When points are given, it draws one polygon that connects all the points in order. When a shape is given (essentially anything decomposable by GeometryBasics), it will plot decompose(shape).

poly(coordinates, connectivity; kwargs...)

Plots polygons, which are defined by coordinates (the coordinates of the vertices) and connectivity (the edges between the vertices).

Attributes

Specific to Poly

  • lowclip::Union{Automatic, Symbol, <:Colorant} = automatic sets a color for any value below the colorrange.

  • highclip::Union{Automatic, Symbol, <:Colorant} = automatic sets a color for any value above the colorrange.

  • strokecolor::Union{Symbol, <:Colorant} = :black sets the color of the outline around a marker.

  • strokewidth::Real = 0 sets the width of the outline around a marker.

  • linestyle::Union{Nothing, Symbol, Vector} = nothing sets the pattern of the line (e.g. :solid, :dot, :dashdot)

Generic

  • visible::Bool = true sets whether the plot will be rendered or not.

  • overdraw::Bool = false sets whether the plot will draw over other plots. This specifically means ignoring depth checks in GL backends.

  • transparency::Bool = false adjusts how the plot deals with transparency. In GLMakie transparency = true results in using Order Independent Transparency.

  • fxaa::Bool = true adjusts whether the plot is rendered with fxaa (anti-aliasing).

  • inspectable::Bool = true sets whether this plot should be seen by DataInspector.

  • color is set by the plot.

  • colormap::Union{Symbol, Vector{<:Colorant}} = [:black, :white sets the colormap that is sampled for numeric colors.

  • colorrange::Tuple{<:Real, <:Real} sets the values representing the start and end points of colormap.

  • nan_color::Union{Symbol, <:Colorant} = RGBAf(0,0,0,0) sets a replacement color for color = NaN.

  • lowclip::Union{Automatic, Symbol, <:Colorant} = automatic sets a color for any value below the colorrange.

  • highclip::Union{Automatic, Symbol, <:Colorant} = automatic sets a color for any value above the colorrange.

  • space::Symbol = :data sets the transformation space for the position of the image. See Makie.spaces() for possible inputs.

  • cycle::Vector{Symbol} = [:color => :patchcolor] sets which attributes to cycle when creating multiple plots.

  • shading = false enables lighting.

Examples

using CairoMakie
using Makie.GeometryBasics


f = Figure()
Axis(f[1, 1])

poly!(Point2f[(0, 0), (2, 0), (3, 1), (1, 1)], color = :red, strokecolor = :black, strokewidth = 1)

f

using CairoMakie
using Makie.GeometryBasics


f = Figure()
Axis(f[1, 1])

# polygon with hole
p = Polygon(
    Point2f[(0, 0), (2, 0), (3, 1), (1, 1)],
    [Point2f[(0.75, 0.25), (1.75, 0.25), (2.25, 0.75), (1.25, 0.75)]]
)

poly!(p, color = :blue)

f

using CairoMakie
using Makie.GeometryBasics


f = Figure()
Axis(f[1, 1])

# vector of shapes
poly!(
    [Rect(i, j, 0.75, 0.5) for i in 1:5 for j in 1:3],
    color = 1:15,
    colormap = :heat
)

f

using CairoMakie
using Makie.GeometryBasics


f = Figure()
Axis(f[1, 1], aspect = DataAspect())

# shape decomposition
poly!(Circle(Point2f(0, 0), 15f0), color = :pink)

f

using CairoMakie
using Makie.GeometryBasics


f = Figure()
Axis(f[1, 1]; backgroundcolor = :gray15)

# vector of polygons
ps = [Polygon(rand(Point2f, 3) .+ Point2f(i, j))
    for i in 1:5 for j in 1:10]

poly!(ps, color = rand(RGBf, length(ps)))

f