pyvista.CompositePolyDataMapper.set_scalars#

CompositePolyDataMapper.set_scalars(
scalars_name,
preference,
component,
annotations,
rgb,
scalar_bar_args,
n_colors,
nan_color,
above_color,
below_color,
clim,
cmap,
flip_scalars,
log_scale,
)[source]#

Set the scalars of the mapper.

Parameters:
scalars_namestr

Name of the scalars in the dataset. Must already exist in at least of the blocks.

preferencestr

For each block, when block.n_points == block.n_cells and setting scalars, this parameter sets how the scalars will be mapped to the mesh. Default 'point', causes the scalars will be associated with the mesh points. Can be either 'point' or 'cell'.

componentint

Set component of vector valued scalars to plot. Must be nonnegative, if supplied. If None, the magnitude of the vector is plotted.

annotationsdict

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.

rgbbool

If the scalars_name corresponds to a 2 dimensional array, plot those values as RGB(A) colors.

scalar_bar_argsdict

Dictionary of keyword arguments to pass when adding the scalar bar to the scene. For options, see pyvista.Plotter.add_scalar_bar().

n_colorsint

Number of colors to use when displaying scalars.

nan_colorColorLike

The color to use for all NaN values in the plotted scalar array.

above_colorColorLike

Solid color for values below the scalars range (clim). This will automatically set the scalar bar above_label to 'above'.

below_colorColorLike

Solid color for values below the scalars range (clim). This will automatically set the scalar bar below_label to 'below'.

climSequence

Color bar range for scalars. Defaults to minimum and maximum of scalars array. Example: [-1, 2]. rng is also an accepted alias for this.

cmapstr, list, or pyvista.LookupTable

Name of the Matplotlib colormap to use when mapping the scalars. See available Matplotlib colormaps. Only applicable for when displaying scalars. colormap is also an accepted alias for this. If colorcet or cmocean are 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 like n_colors will be ignored. are installed, their colormaps can be specified by name.

flip_scalarsbool

Flip direction of cmap. Most colormaps allow *_r suffix to do this as well.

log_scalebool

Use log scale when mapping data to colors. Scalars less than zero are mapped to the smallest representable positive float.

Returns:
dict

Dictionary of scalar bar arguments.