Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Plotly · Class

go.Mesh3d

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.

How it works

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.

Syntax

plotly.graph_objects.Mesh3d(arg=None, **kwargs)

Parameters

NameTypeDescription
xarray-likeVertex x-coordinates used to construct the mesh.
yarray-likeVertex y-coordinates used to construct the mesh.
zarray-likeVertex z-coordinates used to construct the mesh.
iarray-likeFirst vertex index for each explicitly defined triangle.
jarray-likeSecond vertex index for each explicitly defined triangle.
karray-likeThird vertex index for each explicitly defined triangle.
alphahullnumberControls the mesh-shape algorithm: -1 for Delaunay, positive values for alpha shapes, and 0 for the convex hull.
intensityarray-likeValues used to color vertices or cells.
intensitymode"vertex" | "cell"Selects vertex interpolation or cell-level intensity assignment.

Returns

A Plotly Mesh3d graph-object trace.

Key points

  • Use x, y, and z to provide the mesh vertices; the trace renders those points as a 3D triangular surface.
  • For explicit topology, provide i, j, and k arrays whose corresponding entries identify each triangle's three vertex indices.
  • A positive alphahull selects alpha-shape construction, which can produce a different boundary from Delaunay triangulation.
  • Setting alphahull to zero makes the trace represent the convex hull, yielding a convex body.
  • The default vertex intensity mode interpolates color values between vertex-defined intensity values.
  • Cell intensity mode assigns a single value to each triangle and does not interpolate it across the cell.

Common mistakes

  • With alphahull left at its default, Plotly uses Delaunay triangulation; changing it alters how the mesh shape is constructed.
  • When using intensity, its length must match the selected intensity mode: vertices for vertex mode or cells for cell mode.

Example: Explicit tetrahedral mesh

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.

When to use it

Surface visualization

Visualizing a triangulated 3D surface from scattered or regularly sampled points.

Explicit geometric topology

Rendering a custom solid or polyhedral model when triangle connectivity is already known.

Scalar field display

Coloring a mesh by values defined at vertices or assigned to individual cells.

Interview questions

QWhat does go.Mesh3d represent, and how are triangles defined?

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.

QHow does alphahull affect a mesh?

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.

QHow do intensity and intensitymode work together?

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.Figure
  • mesh3d trace reference
  • 3D Mesh Plots in Python

Source: 3D Mesh Plots in Python. Checked 2026-10-15.