Plotter.add_point_scalar_labels

Plotter.add_point_scalar_labels#

Plotter.add_point_scalar_labels(
points: MatrixLike[float] | VectorLike[float] | DataSet,
labels: list[str | int] | str,
fmt: str | None = None,
preamble: str = '',
**kwargs,
) _vtk.vtkActor2D[source]#

Label the points from a dataset with the values of their scalars.

Wrapper for pyvista.Plotter.add_point_labels().

Parameters:
pointssequence[float] | np.ndarray | DataSet

An n x 3 numpy.ndarray or pyvista dataset with points.

labelslist | str

List of scalars of labels. Must be the same length as points. If a string name is given with a pyvista.DataSet input for points, then these are fetched.

fmtstr, optional

String formatter used to format numerical data.

preamblestr, default: “”

Text before the start of each label.

**kwargsdict, optional

Keyword arguments passed to pyvista.Plotter.add_point_labels().

Returns:
vtkActor2D

VTK label actor. Can be used to change properties of the labels.

Examples#

Download Python source code | Download Jupyter notebook

Label points with their elevation.

>>> import pyvista as pv
>>> mesh = pv.Sphere(theta_resolution=8, phi_resolution=8)
>>> mesh['Elevation'] = mesh.points[:, 2]
>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(mesh, scalars='Elevation')
>>> _ = pl.add_point_scalar_labels(
...     mesh,
...     'Elevation',
...     point_size=20,
...     font_size=20,
... )
>>> pl.show()
../../../_images/pyvista-Plotter-add_point_scalar_labels-7f2a5b049f63a51b_00_00.png