DataSetFilters.contour(isosurfaces=10, scalars=None, compute_normals=False, compute_gradients=False, compute_scalars=True, rng=None, preference='point', method='contour', progress_bar=False)

Contour an input self by an array.

isosurfaces can be an integer specifying the number of isosurfaces in the data range or a sequence of values for explicitly setting the isosurfaces.

isosurfacesint or sequence, optional

Number of isosurfaces to compute across valid data range or a sequence of float values to explicitly use as the isosurfaces.

scalarsstr, optional

Name of scalars to threshold on. Defaults to currently active scalars.

compute_normalsbool, optional

Compute normals for the dataset.

compute_gradientsbool, optional

Compute gradients for the dataset.

compute_scalarsbool, optional

Preserves the scalar values that are being contoured.

rngtuple(float), optional

If an integer number of isosurfaces is specified, this is the range over which to generate contours. Default is the scalars array’s full data range.

preferencestr, optional

When scalars is specified, this is the preferred array type to search for in the dataset. Must be either 'point' or 'cell'.

methodstr, optional

Specify to choose which vtk filter is used to create the contour. Must be one of 'contour', 'marching_cubes' and 'flying_edges'. Defaults to 'contour'.

progress_barbool, optional

Display a progress bar to indicate progress.


Contoured surface.


Generate contours for the random hills dataset.

>>> from pyvista import examples
>>> hills = examples.load_random_hills()
>>> contours = hills.contour()
>>> contours.plot(line_width=5)

See Using Common Filters for more examples using this filter.