add_mesh

add_mesh#

Plot3d.add_mesh(mesh, *args, frame=None, **kwargs)[source]#

Add a mesh to the scene, converting coordinates from frame if needed.

Extends pyvista.Plotter.add_mesh() with an optional frame argument. File-path strings are read with pyvista.read() before processing. Composite meshes are routed through add_composite(); single meshes have their points converted to the plotter Cartesian frame via apply_mesh_transform() when frame is set.

Parameters:
meshPlottableType | str | Path

The mesh to add. Accepts any type supported by pyvista.Plotter.add_mesh(), plus file-path strings or pathlib.Path objects that are read automatically.

*args

Additional positional arguments forwarded to pyvista.Plotter.add_mesh().

framestr | None, optional

Coordinate frame of mesh. Any alias accepted by fetch_canonical_frame(). If None, the frame stored in mesh.user_dict['MESH_FRAME'] is used (if present). Default is None.

**kwargs

Additional keyword arguments forwarded to pyvista.Plotter.add_mesh().

Returns:
outpyvista.Actor

The actor returned by the underlying PyVista plotter call.

Examples

Add a SphericalMesh directly — its frame is stored in user_dict and picked up automatically:

>>> import pyvisual as pv
>>> from pyvisual.core.mesh3d import SphericalMesh
>>> import numpy as np
>>> r = np.linspace(1, 5, 20)
>>> t = np.linspace(0, np.pi, 30)
>>> p = np.linspace(0, 2 * np.pi, 60)
>>> mesh = SphericalMesh(r, t, p)
>>> pl = pv.Plot3d()
>>> pl.add_mesh(mesh, color='orange', opacity=0.5)
>>> pl.show()
../../../../../../_images/pyvisual-core-plot3d-Plot3d-add_mesh-57215167a1fa6aac_00_00.png