pyvista.DataSetMapper.set_scalars#
- DataSetMapper.set_scalars(
- scalars,
- scalars_name,
- n_colors=256,
- scalar_bar_args=None,
- rgb=None,
- component=None,
- preference='point',
- custom_opac=False,
- annotations=None,
- log_scale=False,
- nan_color=None,
- above_color=None,
- below_color=None,
- cmap=None,
- flip_scalars=False,
- opacity=None,
- categories=False,
- clim=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
pyvista.ColorLike,optional The color to use for all
NaNvalues in the plotted scalar array.- above_color
pyvista.ColorLike,optional Solid color for values below the scalars range (
clim). This will automatically set the scalar barabove_labelto'above'.- below_color
pyvista.ColorLike,optional Solid color for values below the scalars range (
clim). This will automatically set the scalar barbelow_labelto'below'.- cmap
str,list,orpyvista.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
strornumpy.ndarray,optional Opacity mapping for the scalars array. A string can also be specified to map the scalars range to a predefined opacity transfer function (options include: ‘linear’, ‘linear_r’, ‘geom’, ‘geom_r’). Or you can pass a custom made transfer function that is an array either
n_colorsin length or shorter.- categoriesbool, default:
False If set to
True, then the number of unique values in the scalar array will be used as then_colorsargument.- clim
Sequence,optional Color bar range for scalars. Defaults to minimum and maximum of scalars array. Example:
(-1, 2).
- scalars