Visualization

The package exports a single viz command that can be used to add objects to the scene with a consistent set of options.

Meshes.vizFunction
viz(object; [options])

Visualize Meshes.jl object with various options.

Available options

  • color - color of geometries
  • alpha - transparency in [0,1]
  • colormap - color scheme/map from ColorSchemes.jl
  • colorrange - minimum and maximum color values
  • showsegments - visualize segments
  • segmentcolor - color of segments
  • segmentsize - width of segments
  • showpoints - visualize points
  • pointmarker - marker of points
  • pointcolor - color of points
  • pointsize - size of points

The option color can be a single scalar or a vector of scalars. For Mesh subtypes, the length of the vector of colors determines if the colors should be assigned to vertices or to elements.

Examples

Different coloring methods (vertex vs. element):

# vertex coloring (i.e. linear interpolation)
viz(mesh, color = 1:nvertices(mesh))

# element coloring (i.e. discrete colors)
viz(mesh, color = 1:nelements(mesh))

Different strategies to show the boundary of geometries (showsegments vs. boundary):

# visualize boundary with showsegments
viz(polygon, showsegments = true)

# visualize boundary with separate call
viz(polygon)
viz!(boundary(polygon))

Notes

  • This function will only work in the presence of a Makie.jl backend via package extensions in Julia v1.9 or later versions of the language.
source
Meshes.viz!Function
viz!(object; [options])

Visualize Meshes.jl object in an existing scene with options forwarded to viz.

source

Geometries

We can visualize a single geometry or multiple geometries in a vector:

triangles = rand(Triangle, 10, crs=Cartesian2D)

viz(triangles, color = 1:10)
Example block output

Domains

Alternatively, we can visualize domains with topological information such as Mesh and show facets efficiently:

grid = CartesianGrid(10, 10, 10)

viz(grid, showsegments = true, segmentcolor = :teal)
Example block output