pyvista.ImageData.spacing

pyvista.ImageData.spacing#

property ImageData.spacing: tuple[float, float, float][source]#

Return or set the spacing for each axial direction.

Notes

Spacing must be non-negative. While VTK accepts negative spacing, this results in unexpected behavior. See: pyvista/pyvista#1967

Examples

Create a 5 x 5 x 5 uniform grid.

>>> import pyvista as pv
>>> grid = pv.ImageData(dimensions=(5, 5, 5))
>>> grid.spacing
(1.0, 1.0, 1.0)
>>> grid.plot(show_edges=True)
../../../_images/pyvista-ImageData-spacing-1_00_00.png

Modify the spacing to (1, 2, 3)

>>> grid.spacing = (1, 2, 3)
>>> grid.plot(show_edges=True)
../../../_images/pyvista-ImageData-spacing-1_01_00.png