_StructuredDataMixin.offset

_StructuredDataMixin.offset#

property _StructuredDataMixin.offset: tuple[int, int, int][source]#

Return or set the index offset of the grid.

The offset is simply the first indices for each of the three axes and defines the minimum extent of the grid. Offset values can be positive or negative. Setting the offset keeps the grid’s dimensions.

For an ImageData, the offset is relative to the origin in physical space. For other grids, the points do not move.

Added in version 0.45.

Changed in version 0.50: Available on RectilinearGrid, StructuredGrid and ExplicitStructuredGrid.

Examples#

Download Python source code | Download Jupyter notebook

Create an ImageData and show that the offset is zeros by default.

>>> import pyvista as pv
>>> grid = pv.ImageData(dimensions=(10, 10, 10))
>>> grid.offset
(0, 0, 0)

The offset defines the minimum extent.

>>> grid.extent
(0, 9, 0, 9, 0, 9)

Set the offset to a new value for all axes.

>>> grid.offset = 2
>>> grid.offset
(2, 2, 2)

Show the extent again. Note how all values have increased by the offset value.

>>> grid.extent
(2, 11, 2, 11, 2, 11)

Set the offset for each axis separately and show the extent again.

>>> grid.offset = (-1, -2, -3)
>>> grid.extent
(-1, 8, -2, 7, -3, 6)

Set the offset of a StructuredGrid. Its points, and therefore its bounds, are unchanged.

>>> grid = pv.ImageData(dimensions=(3, 3, 3)).cast_to_structured_grid()
>>> grid.offset = (-1, -2, -3)
>>> grid.extent
(-1, 1, -2, 0, -3, -1)
>>> grid.bounds
BoundsTuple(x_min = 0.0,
            x_max = 2.0,
            y_min = 0.0,
            y_max = 2.0,
            z_min = 0.0,
            z_max = 2.0)