Plotter.update_scalar_bar_range

Plotter.update_scalar_bar_range#

Plotter.update_scalar_bar_range(
clim: float | Sequence[float],
name: str | None = None,
) → None[source]#

Update the value range of the active or named scalar bar.

Every mapper sharing the scalar bar follows the new range.

Parameters:
climsequence[float]

The new range of scalar bar. For example [-1, 2].

namestr, optional

The title of the scalar bar to update.

Examples#

Download Python source code | Download Jupyter notebook

Update the range of a named scalar bar.

>>> import pyvista as pv
>>> mesh = pv.Sphere()
>>> mesh['height'] = mesh.points[:, 2]
>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(
...     mesh,
...     scalars='height',
...     clim=(-0.5, 0.5),
...     scalar_bar_args={'title': 'Height'},
... )
>>> pl.update_scalar_bar_range((-1, 1), name='Height')
>>> pl.show()
../../../_images/pyvista-Plotter-update_scalar_bar_range-3ce28bbe5fc85ee0_00_00.png