_StructuredDataMixin.dimensions

_StructuredDataMixin.dimensions#

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

Return or set the grid’s dimensions.

These are effectively the number of points along each of the three dataset axes. New dimensions must be all positive, or all zero for an empty grid. Setting the dimensions keeps the grid’s offset.

The dimensions of a RectilinearGrid and an ExplicitStructuredGrid are defined by their coordinates and cells and cannot be set. The dimensions of a StructuredGrid are checked against its number of points when they are set, so set its points first.

Returns:
tuple[int, int, int]

Dimensions of the grid.

Examples#

Download Python source code | Download Jupyter notebook

Create a uniform grid with dimensions (2, 3, 4).

>>> import pyvista as pv
>>> grid = pv.ImageData(dimensions=(2, 3, 4))
>>> grid.dimensions
(2, 3, 4)
>>> grid.plot(show_edges=True)
../../../_images/pyvista-core-_structured_data-_StructuredDataMixin-dimensions-1c294bcb64831bba_00_00.png

Set the dimensions to (3, 4, 5).

>>> grid.dimensions = (3, 4, 5)
>>> grid.plot(show_edges=True)
../../../_images/pyvista-core-_structured_data-_StructuredDataMixin-dimensions-1c294bcb64831bba_01_00.png