triplot
triplot(x, y; kwargs...)
triplot(positions; kwargs...)
triplot(triangles::Triangulation; kwargs...)Plots a triangulation based on the provided position or Triangulation from DelaunayTriangulation.jl.
Attributes
show_points = falsedetermines whether to plot the individual points. Note that this will only plot points included in the triangulation.show_convex_hull = falsedetermines whether to plot the convex hull.show_ghost_edges = falsedetermines whether to plot the ghost edges.show_constrained_edges = falsedetermines whether to plot the constrained edges.recompute_centers = falsedetermines whether to recompute the representative points for the ghost edge orientation. Note that this will mutatetri.representative_point_listdirectly.markersize = 12sets the size of the points.marker = :circlesets the shape of the points.markercolor = :blacksets the color of the points.strokecolor = :blacksets the color of triangle edges.strokewidth = 1sets the linewidth of triangle edges.linestyle = :solidsets the linestyle of triangle edges.triangle_color = (:white, 0.0)sets the color of the triangles.convex_hull_color = :redsets the color of the convex hull.convex_hull_linestyle = :dashsets the linestyle of the convex hull.convex_hull_linewidth = 1sets the width of the convex hull.ghost_edge_color = :bluesets the color of the ghost edges.ghost_edge_linestyle = :solidsets the linestyle of the ghost edges.ghost_edge_linewidth = 1sets the width of the ghost edges.ghost_edge_extension_factor = 0.1sets the extension factor for the rectangle that the exterior ghost edges are extended onto.bounding_box::Union{Automatic, Rect2, Tuple} = automatic: Sets the bounding box for truncating ghost edges which can be aRect2(orBBox) or a tuple of the form(xmin, xmax, ymin, ymax). By default, the rectangle will be given by[a - eΔx, b + eΔx] × [c - eΔy, d + eΔy]whereeis theghost_edge_extension_factor,Δx = b - aandΔy = d - care the lengths of the sides of the rectangle, and[a, b] × [c, d]is the bounding box of the points in the triangulation.constrained_edge_color = :magentasets the color of the constrained edges.constrained_edge_linestyle = :solidsets the linestyle of the constrained edges.constrained_edge_linewidth = 1sets the width of the constrained edges.
Examples
A triplot plots a triangle mesh generated from an arbitrary set of points. The input data can either be point based (like scatter or lines) or a Triangulation from DelaunayTriangulation.jl.
using CairoMakie
using DelaunayTriangulation
using Random
Random.seed!(1234)
points = randn(Point2f, 50)
f, ax, tr = triplot(points, show_points = true, triangle_color = :lightblue)
tri = triangulate(points)
ax, tr = triplot(f[1, 2], tri, show_points = true)
fYou can use triplot to visualise the ghost edges surrounding the boundary.
using CairoMakie
using DelaunayTriangulation
n = 20
angles = range(0, 2pi, length = n+1)[1:end-1]
x = [cos.(angles); 2 .* cos.(angles .+ pi/n)]
y = [sin.(angles); 2 .* sin.(angles .+ pi/n)]
inner = [n:-1:1; n] # clockwise inner
outer = [(n+1):(2n); n+1] # counter-clockwise outer
boundary_nodes = [[outer], [inner]]
points = [x'; y']
tri = triangulate(points; boundary_nodes = boundary_nodes)
f, ax, tr = triplot(tri; show_ghost_edges = true, show_points = true)
fYou can also highlight the constrained edges and display the convex hull, which is especially useful when the triangulation is no longer convex.
using CairoMakie
using DelaunayTriangulation
using Random
Random.seed!(1234)
outer = [
(0.0,0.0),(2.0,1.0),(4.0,0.0),
(6.0,2.0),(2.0,3.0),(3.0,4.0),
(6.0,6.0),(0.0,6.0),(0.0,0.0)
]
inner = [
(1.0,5.0),(2.0,4.0),(1.01,1.01),
(1.0,1.0),(0.99,1.01),(1.0,5.0)
]
boundary_points = [[outer], [inner]]
boundary_nodes, points = convert_boundary_points_to_indices(boundary_points)
tri = triangulate(points; boundary_nodes = boundary_nodes)
refine!(tri; max_area=1e-3get_total_area(tri))
f, ax, tr = triplot(tri, show_constrained_edges = true, constrained_edge_linewidth = 4, show_convex_hull = true)
fThese docs were autogenerated using Makie: v0.19.12, GLMakie: v0.8.12, CairoMakie: v0.10.12, WGLMakie: v0.8.16