cell_centers

UniformGrid.cell_centers(vertex=True, progress_bar=False)

Generate points at the center of the cells in this dataset.

These points can be used for placing glyphs or vectors.

Parameters
vertexbool

Enable or disable the generation of vertex cells.

progress_barbool, optional

Display a progress bar to indicate progress.

Returns
pyvista.PolyData

Polydata where the points are the cell centers of the original dataset.

Examples

>>> import pyvista
>>> mesh = pyvista.Plane()
>>> mesh.point_data.clear()
>>> centers = mesh.cell_centers()
>>> pl = pyvista.Plotter()
>>> actor = pl.add_mesh(mesh, show_edges=True)
>>> actor = pl.add_points(centers, render_points_as_spheres=True,
...                       color='red', point_size=20)
>>> pl.show()
../../../_images/pyvista-UniformGrid-cell_centers-1_00_00.png

See Extract Cell Centers for more examples using this filter.