Surface visualization
Visualizing a triangulated 3D surface from scattered or regularly sampled points.
Plotly · Class
go.Mesh3d draws a 3D triangular mesh from vertex coordinates. Plotly can triangulate the coordinates automatically, or accept explicit triangle indices through i, j, and k.
Mesh3d is a Plotly graph-object trace for representing a 3D surface as triangles. Give vertex coordinates through x, y, and z; Plotly can triangulate them automatically, or you can define the triangles explicitly with i, j, and k. Intensity can be mapped either across vertices or per cell.
plotly.graph_objects.Mesh3d(arg=None, **kwargs)| Name | Type | Description |
|---|---|---|
x | array-like | Vertex x-coordinates used to construct the mesh. |
y | array-like | Vertex y-coordinates used to construct the mesh. |
z | array-like | Vertex z-coordinates used to construct the mesh. |
i | array-like | First vertex index for each explicitly defined triangle. |
j | array-like | Second vertex index for each explicitly defined triangle. |
k | array-like | Third vertex index for each explicitly defined triangle. |
alphahull | number | Controls the mesh-shape algorithm: -1 for Delaunay, positive values for alpha shapes, and 0 for the convex hull. |
intensity | array-like | Values used to color vertices or cells. |
intensitymode | "vertex" | "cell" | Selects vertex interpolation or cell-level intensity assignment. |
A Plotly Mesh3d graph-object trace.
import plotly.graph_objects as go
fig = go.Figure(go.Mesh3d(
x=[0, 1, 0, 0],
y=[0, 0, 1, 0],
z=[0, 0, 0, 1],
i=[0, 0, 0, 1],
j=[1, 1, 2, 2],
k=[2, 3, 3, 3],
intensity=[0, 1, 2, 3],
intensitymode="vertex"
))
fig.show()Creates a tetrahedral 3D mesh from vertex coordinates and explicit triangle-index arrays, then colors vertices by interpolated intensity.
Visualizing a triangulated 3D surface from scattered or regularly sampled points.
Rendering a custom solid or polyhedral model when triangle connectivity is already known.
Coloring a mesh by values defined at vertices or assigned to individual cells.
Mesh3d represents a 3D collection of triangles. The x, y, and z arrays supply vertices; if i, j, and k are omitted, Plotly can generate triangles with Delaunay triangulation.
Follow-up: How would you provide a predefined surface? Supply i, j, and k, where each aligned triplet identifies one triangle by indexing the vertex arrays.
alphahull controls the mesh construction. Its default value of -1 selects Delaunay triangulation, a positive value selects the alpha-shape algorithm, and zero produces the convex hull.
Follow-up: What is the practical distinction between zero and a positive value? Zero creates a convex body, whereas a positive value uses an alpha shape to determine the form.
intensitymode determines how intensity is applied. Vertex mode, the default, interpolates values between vertices; cell mode assigns one value to each triangle without interpolation.
Follow-up: What validation is needed when switching modes? Ensure intensity has one value per vertex in vertex mode or one value per cell in cell mode.
plotly.graph_objects.Figuremesh3d trace reference3D Mesh Plots in Python