pyvista.examples.cells.plot_cell

Contents

pyvista.examples.cells.plot_cell#

plot_cell(
grid: PolyData | UnstructuredGrid,
cpos=None,
*,
line_width: int | None = None,
point_size: int | None = None,
font_size: int | None = None,
show_normals: bool = False,
normals_scale: float | None = None,
**kwargs,
)[source]#

Plot a mesh while displaying cell indices.

Changed in version 0.45: The default line width, point size, and font size are increased from 5, 30 and 20 to 10, 80, and 50, respectively.

Changed in version 0.47: The default line width, point size, and font size are restored to their original values prior to version 0.45. These values can now be customized with keywords.

Parameters:
gridPolyData | UnstructuredGrid

Dataset containing one single cell (ideally), though plotting a mesh with multiple cells is supported.

Changed in version 0.47: Plotting PolyData is now supported.

cposstr, optional

Camera position.

line_widthint, default: 5

Line width of the cell’s edges.

Added in version 0.47.

point_sizeint, default: 30

Size of the cell’s points.

Added in version 0.47.

font_sizeint, default: 20

Size of the point labels.

Added in version 0.47.

show_normalsbool, optional

Show the face normals of the cell. Only applies to 2D or 3D cells. Cell faces with correct orientation should have the normal pointing outward.

The size of the normals is controlled by normals_scale.

Added in version 0.47.

normals_scalefloat, default: 0.1

Scale factor used when show_normals is enabled. The normals are scaled proportional to the diagonal length of the input grid.

Added in version 0.47.

**kwargsdict, optional

Additional keyword arguments when showing. See pyvista.Plotter.show().

Examples

Create and plot a single hexahedron.

>>> from pyvista import examples
>>> grid = examples.cells.Hexahedron()
>>> examples.plot_cell(grid)
../../../_images/pyvista-examples-cells-plot_cell-6553cf38f17755fe_00_00.png

Show normals and customize the size of various elements in the rendering.

>>> examples.plot_cell(
...     grid,
...     show_normals=True,
...     normals_scale=0.2,
...     line_width=8,
...     point_size=50,
...     font_size=30,
... )
../../../_images/pyvista-examples-cells-plot_cell-6553cf38f17755fe_01_00.png