pyvista.DataSetFilters.glyph#

DataSetFilters.glyph(orient=True, scale=True, factor=1.0, geom=None, indices=None, tolerance=None, absolute=False, clamping=False, rng=None, progress_bar=False)[source]#

Copy a geometric representation (called a glyph) to the input dataset.

The glyph may be oriented along the input vectors, and it may be scaled according to scalar data or vector magnitude. Passing a table of glyphs to choose from based on scalars or vector magnitudes is also supported. The arrays used for orient and scale must be either both point data or both cell data.

Parameters:
orientbool | str, default: True

If True, use the active vectors array to orient the glyphs. If string, the vector array to use to orient the glyphs. If False, the glyphs will not be orientated.

scalebool | str | sequence[float], default: True

If True, use the active scalars to scale the glyphs. If string, the scalar array to use to scale the glyphs. If False, the glyphs will not be scaled.

factorfloat, default: 1.0

Scale factor applied to scaling array.

geomvtk.vtkDataSet or tuple(vtk.vtkDataSet), optional

The geometry to use for the glyph. If missing, an arrow glyph is used. If a sequence, the datasets inside define a table of geometries to choose from based on scalars or vectors. In this case a sequence of numbers of the same length must be passed as indices. The values of the range (see rng) affect lookup in the table.

indicessequence[float], optional

Specifies the index of each glyph in the table for lookup in case geom is a sequence. If given, must be the same length as geom. If missing, a default value of range(len(geom)) is used. Indices are interpreted in terms of the scalar range (see rng). Ignored if geom has length 1.

tolerancefloat, optional

Specify tolerance in terms of fraction of bounding box length. Float value is between 0 and 1. Default is None. If absolute is True then the tolerance can be an absolute distance. If None, points merging as a preprocessing step is disabled.

absolutebool, default: False

Control if tolerance is an absolute distance or a fraction.

clampingbool, default: False

Turn on/off clamping of “scalar” values to range.

rngsequence[float], optional

Set the range of values to be considered by the filter when scalars values are provided.

progress_barbool, default: False

Display a progress bar to indicate progress.

Returns:
pyvista.PolyData

Glyphs at either the cell centers or points.

Examples

Create arrow glyphs oriented by vectors and scaled by scalars. Factor parameter is used to reduce the size of the arrows.

>>> import pyvista as pv
>>> from pyvista import examples
>>> mesh = examples.load_random_hills()
>>> arrows = mesh.glyph(
...     scale="Normals", orient="Normals", tolerance=0.05
... )
>>> pl = pv.Plotter()
>>> actor = pl.add_mesh(arrows, color="black")
>>> actor = pl.add_mesh(
...     mesh,
...     scalars="Elevation",
...     cmap="terrain",
...     show_scalar_bar=False,
... )
>>> pl.show()
../../../_images/pyvista-DataSetFilters-glyph-1_00_00.png

See Plotting Glyphs (Vectors or PolyData) and Table of Glyphs for more examples using this filter.