pyvista.DataObjectFilters.slice#
- DataObjectFilters.slice(
- normal: VectorLike[float] | NormalsLiteral = 'x',
- origin: VectorLike[float] | None = None,
- generate_triangles: bool = False,
- contour: bool = False,
- progress_bar: bool = False,
Slice a dataset by a plane at the specified origin and normal vector orientation.
If no origin is specified, the center of the input dataset will be used.
- Parameters:
- normalsequence[
float] |str, default: ‘x’ Length 3 tuple for the normal vector direction. Can also be specified as a string conventional direction such as
'x'for(1, 0, 0)or'-x'for(-1, 0, 0), etc.- originsequence[
float],optional The center
(x, y, z)coordinate of the plane on which the slice occurs.- generate_trianglesbool, default:
False If this is enabled (
Falseby default), the output will be triangles. Otherwise the output will be the intersection polygons.- contourbool, default:
False If
True, apply acontourfilter after slicing.- progress_barbool, default:
False Display a progress bar to indicate progress.
- normalsequence[
- Returns:
pyvista.PolyDataSliced dataset.
Examples
Slice the surface of a sphere.
>>> import pyvista as pv >>> sphere = pv.Sphere() >>> slice_x = sphere.slice(normal='x') >>> slice_y = sphere.slice(normal='y') >>> slice_z = sphere.slice(normal='z') >>> slices = slice_x + slice_y + slice_z >>> slices.plot(line_width=5)
See Slicing for more examples using this filter.