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)
https://d33wubrfki0l68.cloudfront.net/fcb30f33aa0ef90dc03e019d48c5d4278c07200c/f7a35/_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/23a385eee45116fbb2ca64b0903a41b2e79d731d/c3f7c/_images/pyvista-imagedata-spacing-1_01_00.png