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
>>> grid = pyvista.ImageData(dimensions=(5, 5, 5))
>>> grid.spacing
(1.0, 1.0, 1.0)
>>> grid.plot(show_edges=True)
https://d33wubrfki0l68.cloudfront.net/e753c550c5a27aec5d3fe23b376cd3897da1e4a4/26a4a/_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)
https://d33wubrfki0l68.cloudfront.net/e8bb9092e2ca54521a532548fcf6abcf4b17b244/daa27/_images/pyvista-imagedata-spacing-1_01_00.png