lapy.plot

Functions for plotting Tet and Tria Meshes with overlays.

For visualizing results in a juypter notebook use this:

.. code-block:: python

    import plotly
    plotly.offline.init_notebook_mode(connected=True)
    ...
lapy.plot.plot_tet_mesh(tetra, vfunc=None, plot_edges=False, plot_levels=False, tfunc=None, cutting=None, edge_color='rgb(50,50,50)', html_output=False, width=800, height=800, flatshading=False, xrange=None, yrange=None, zrange=None, showcaxis=False, caxis=None)[source]

Plot tetra meshes.

The tetra mesh will be converted to its tria boundary mesh, and only this will be plotted.

Parameters:
tetraTetMesh

Tetrahedral mesh to plot.

vfuncnp.ndarray, default=None

Scalar function at vertices, shape (n_vertices,).

plot_edgesbool, default=False

Whether to plot edges or not.

plot_levelsbool, default=False

Whether to plot levels or not.

tfuncnp.ndarray, default=None

3D vector function of gradient, shape (n_tetrahedra,) or (n_tetrahedra, 3).

cuttingstr or list of str, default=None

To view the ‘interior’ of the tetra mesh, one or more cutting criteria can be defined as input arguments to this function: e.g. cutting=(‘x<-10’) or cutting=(‘z>=5’) or cutting=(‘f>4’) where x,y,z represent dimensions 0,1,2 of the vertex array, and f represents the vfunc (which cannot be None if f is used to define a cutting criterion).

edge_colorstr, default=”rgb(50,50,50)”

Color of the edges.

html_outputbool, default=False

Whether or not to give out as html output.

widthint, default=800

Width of the plot (in px).

heightint, default=800

Height of the plot (in px).

flatshadingbool, default=False

Whether normal smoothing is applied to the meshes or not.

xrangelist or tuple of float, default=None

Sets the range of the x-axis as [min, max].

yrangelist or tuple of float, default=None

Sets the range of the y-axis as [min, max].

zrangelist or tuple of float, default=None

Sets the range of the z-axis as [min, max].

showcaxisbool, default=False

Whether a colorbar is displayed or not.

caxislist or tuple of float, default=None

Sets the bound of the color domain as [lower_bound, upper_bound].

Raises:
ValueError

If tetra is not a TetMesh instance, or if vfunc is None when ‘f’ is used in cutting criteria.

lapy.plot.plot_tria_mesh(tria, vfunc=None, tfunc=None, vcolor=None, tcolor=None, showcaxis=False, caxis=None, xrange=None, yrange=None, zrange=None, plot_edges=False, plot_levels=False, edge_color='rgb(50,50,50)', tic_color='rgb(50,200,10)', background_color=None, flatshading=False, width=800, height=800, camera=None, html_output=False, export_png=None, scale_png=1.0, no_display=False)[source]

Plot tria mesh.

Parameters:
triaTriaMesh

Triangle mesh to plot.

vfuncnp.ndarray, default=None

Scalar function at vertices, shape (n_vertices,) or (n_vertices, N).

tfuncnp.ndarray, default=None

3D vector function of gradient, shape (n_triangles,) or (n_triangles, 3).

vcolorlist of str, default=None

Sets the color of each vertex, shape (n_vertices,).

tcolorlist of str, default=None

Sets the color of each face, shape (n_triangles,).

showcaxisbool, default=False

Whether a colorbar is displayed or not.

caxislist or tuple of float, default=None

Sets the bound of the color domain as [lower_bound, upper_bound].

xrangelist or tuple of float, default=None

Sets the range of the x-axis as [min, max].

yrangelist or tuple of float, default=None

Sets the range of the y-axis as [min, max].

zrangelist or tuple of float, default=None

Sets the range of the z-axis as [min, max].

plot_edgesbool, default=False

Whether to plot edges or not.

plot_levelsbool, default=False

Whether to plot levels or not.

edge_colorstr, default=”rgb(50,50,50)”

Color of the edges.

tic_colorstr, default=”rgb(50,200,10)”

Color of the ticks.

background_colorstr, default=None

Color of background.

flatshadingbool, default=False

Whether normal smoothing is applied to the meshes or not.

widthint, default=800

Width of the plot (in px).

heightint, default=800

Height of the plot (in px).

cameradict, default=None

Camera dictionary with keys ‘center’, ‘eye’, and ‘up’, each containing a dict with x, y, z coordinates.

html_outputbool, default=False

Whether or not to give out as html output.

export_pngstr, default=None

Local file path or file object to write the image to.

scale_pngfloat, default=1.0

Scale factor of image. >1.0 increase resolution; <1.0 decrease resolution.

no_displaybool, default=False

Whether to plot on display or not.

Raises:
ValueError

If tria is not a TriaMesh instance, or if both vfunc/tfunc and vcolor/tcolor are specified, or if both vcolor and tcolor are specified, or if tfunc has invalid dimensions.