_BaseDataSetMapper.set_scalars#
- _BaseDataSetMapper.set_scalars(
- scalars: _AnyArrayLike,
- scalars_name: str,
- *,
- n_colors: int = 256,
- scalar_bar_args: ScalarBarArgs | None = None,
- rgb: bool | None = None,
- component: int | None = None,
- preference: PointLiteral | CellLiteral = 'point',
- custom_opac: bool = False,
- annotations: dict[float, str] | None = None,
- log_scale: bool = False,
- nan_color: ColorLike | None = None,
- above_color: ColorLike | None = None,
- below_color: ColorLike | None = None,
- cmap: ColormapOptions | LookupTable | None = None,
- flip_scalars: bool = False,
- opacity: NDArray[_Real] | None = None,
- categories: bool | int = False,
- clim: float | VectorLikeFloat | None = None,
Set the scalars on this mapper.
- Parameters:
- scalars
numpy.ndarray Array of scalars to assign to the mapper.
- scalars_name
str If the name of this array exists, scalars is ignored. Otherwise, the scalars will be added to the existing dataset and this parameter is the name to assign the scalars.
- n_colors
int, default: 256 Number of colors to use when displaying scalars.
- scalar_bar_args
dict, optional Dictionary of keyword arguments to pass when adding the scalar bar to the scene. For options, see
pyvista.Plotter.add_scalar_bar().- rgbbool, default:
False If an 2 dimensional array is passed as the scalars, plot those values as RGB(A) colors.
rgbais also an accepted alias for this. Opacity (the A) is optional. If a scalars array ending with"_rgba"is passed, the default becomesTrue. This can be overridden by setting this parameter toFalse.- component
int, optional Set component of vector valued scalars to plot. Must be nonnegative, if supplied. If
None, the magnitude of the vector is plotted.- preference
str, default: ‘Point’ When
dataset.n_points == dataset.n_cellsand setting scalars, this parameter sets how the scalars will be mapped to the mesh. Can be either'point'or'cell'.- custom_opacbool, default:
False Use custom opacity.
- annotations
dict, optional Pass a dictionary of annotations. Keys are the float values in the scalars range to annotate on the scalar bar and the values are the string annotations.
- log_scalebool, default:
False Use log scale when mapping data to colors. Scalars less than zero are mapped to the smallest representable positive float.
- nan_color
ColorLike, optional The color to use for all
NaNvalues in the plotted scalar array.- above_color
ColorLike, optional Solid color for values below the scalars range (
clim). This will automatically set the scalar barabove_labelto'above'.- below_color
ColorLike, optional Solid color for values below the scalars range (
clim). This will automatically set the scalar barbelow_labelto'below'.- cmap
str|list|pyvista.LookupTable Name of the Matplotlib colormap to use when mapping the
scalars. See available Matplotlib colormaps. Only applicable for when displayingscalars.colormapis also an accepted alias for this. Ifcolorcetorcmoceanare installed, their colormaps can be specified by name.You can also specify a list of colors to override an existing colormap with a custom one. For example, to create a three color colormap you might specify
['green', 'red', 'blue'].This parameter also accepts a
pyvista.LookupTable. If this is set, all parameters controlling the color map liken_colorswill be ignored.- flip_scalarsbool, default:
False Flip direction of
cmap. Most colormaps allow*_rsuffix to do this as well.- opacity
numpy.ndarray, optional Opacity mapping for the scalars array. With
custom_opacthis is one value per point or cell. Otherwise it is applied to the lookup table and is eithern_colorsin length or shorter.- categoriesbool |
int, default:False If
True, each unique value in the scalar array gets its own color and is labelled on the scalar bar, and values between them take the NaN color. An integer is used as then_colorsargument instead.Changed in version 0.50:
Truegives every unique value its own color instead of spreading the colormap evenly over the scalar range.- clim
VectorLikeFloat|float, optional Color bar range for scalars. Defaults to minimum and maximum of scalars array. Example:
(-1, 2). A single valuecis the range(-c, c).
- scalars