pyvista.Plotter.add_mesh_isovalue#

Plotter.add_mesh_isovalue(mesh, scalars=None, compute_normals=False, compute_gradients=False, compute_scalars=True, preference='point', title=None, pointa=(0.4, 0.9), pointb=(0.9, 0.9), widget_color=None, **kwargs)[source]#

Create a contour of a mesh with a slider.

Add a mesh to the scene with a slider widget that is used to contour at an isovalue of the point data on the mesh interactively.

The isovalue mesh is saved to the .isovalue_meshes attribute on the plotter.

Warning

This will not work with pyvista.PointSet as creating an isovalue is a dimension reducing operation on the geometry and point clouds are zero dimensional. This will similarly fail for point clouds in pyvista.PolyData.

Parameters:
meshpyvista.DataSet or vtk.vtkAlgorithm

The input dataset to add to the scene and contour or algorithm that produces said mesh.

scalarsstr, optional

The string name of the scalars on the mesh to contour and display.

compute_normalsbool, optional

Enable or disable the computation of normals. If the output data will be processed by filters that modify topology or geometry, it may be wise to disable computing normals.

compute_gradientsbool, optional

Enable or disable the computation of gradients. If the output data will be processed by filters that modify topology or geometry, it may be wise to disable computing gradients.

compute_scalarsbool, optional

Enable or disable the computation of scalars.

preferencestr, optional

When mesh.n_points == mesh.n_cells and setting scalars, this parameter sets how the scalars will be mapped to the mesh. Default 'point', causes the scalars will be associated with the mesh points. Can be either 'point' or 'cell'.

titlestr, optional

The string label of the slider widget.

pointasequence, optional

The relative coordinates of the left point of the slider on the display port.

pointbsequence

The relative coordinates of the right point of the slider on the display port.

widget_colorColorLike, optional

Color of the widget. Either a string, RGB sequence, or hex color string. For example:

  • color='white'

  • color='w'

  • color=[1.0, 1.0, 1.0]

  • color='#FFFFFF'

**kwargsdict, optional

All additional keyword arguments are passed to Plotter.add_mesh() to control how the mesh is displayed.

Returns:
vtk.vtkActor

VTK actor of the mesh.

Examples

Shows an interactive slider controlling the altitude of the contours.

>>> import pyvista as pv
>>> from pyvista import examples
>>> pl = pv.Plotter()
>>> mesh = examples.load_random_hills()
>>> _ = pl.add_mesh(mesh, opacity=0.4)
>>> _ = pl.add_mesh_isovalue(mesh)
>>> pl.show()
../../../_images/pyvista-Plotter-add_mesh_isovalue-1_00_00.png