differt.plotting.draw_mesh

Contents

differt.plotting.draw_mesh#

draw_mesh(vertices, triangles, **kwargs)[source]#

Plot a 3D mesh made of triangles.

Parameters:
  • vertices (Real[ArrayLike, 'num_vertices 3']) – The array of triangle vertices.

  • triangles (Int[ArrayLike, 'num_triangles 3']) – The array of triangle indices.

  • kwargs (Any) –

    Keyword arguments passed to Mesh, plot_trisurf, or Mesh3d, depending on the backend.

    Important

    If you pass some face_colors keyword argument, it will be passed to Plotly as facecolor unless they were manually passed, in which case the face_colors argument is ignored. Matplotlib does not currently support individual face colors, so this argument is ignored.

Return type:

Any

Returns:

The resulting plot output.

Examples

The following example shows how to plot a pyramid mesh.

>>> from differt.plotting import draw_mesh
>>>
>>> vertices = np.array([
...     [0.0, 0.0, 0.0],
...     [1.0, 0.0, 0.0],
...     [1.0, 1.0, 0.0],
...     [0.0, 1.0, 0.0],
...     [0.5, 0.5, 1.0],
... ])
>>> triangles = np.array([
...     [0, 1, 2],
...     [0, 2, 3],
...     [0, 1, 4],
...     [1, 2, 4],
...     [2, 3, 4],
...     [3, 0, 4],
... ])
>>> fig = draw_mesh(vertices, triangles, backend="plotly", opacity=0.5)
>>> fig