pyvista.DataSetFilters.glyph

pyvista.DataSetFilters.glyph#

DataSetFilters.glyph(
orient: bool | str = True,
scale: bool | str = True,
factor: float = 1.0,
geom: _vtk.vtkDataSet | Sequence[_vtk.vtkDataSet] | None = None,
indices: VectorLike[int] | None = None,
tolerance: float | None = None,
absolute: bool = False,
clamping: bool = False,
rng: VectorLike[float] | None = None,
color_mode: Literal['scale', 'scalar', 'vector'] = 'scale',
progress_bar: bool = 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.

Note

The reference direction is relative to (1, 0, 0) on the provided geometry. That is, the provided geometry will be rotated from (1, 0, 0) to the direction of the orient vector at each point.

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.

color_modestr, optional, default: 'scale'

If 'scale' , color the glyphs by scale. If 'scalar' , color the glyphs by scalar. If 'vector' , color the glyphs by vector.

Added in version 0.44.

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.