pyvista.LookupTable#
- class LookupTable(
- cmap=None,
- n_values=256,
- flip: bool = False,
- values=None,
- value_range=None,
- hue_range=None,
- alpha_range=None,
- scalar_range=None,
- log_scale=None,
- nan_color=None,
- above_range_color=None,
- below_range_color=None,
- ramp=None,
- annotations=None,
Scalar to RGBA mapping table.
A lookup table is an array that maps input values to output values. When plotting data over a dataset, it is necessary to map those scalars to colors (in the RGBA format), and this class provides the functionality to do so.
See vtkLookupTable for more details regarding the underlying VTK API.
- Parameters:
- cmap
str
|colors.Colormap
,optional
Color map from
matplotlib
,colorcet
, orcmocean
. Eithercmap
orvalues
can be set, but not both.- n_values
int
, default: 256 Number of colors in the color map.
- flipbool, default:
False
Flip the direction of cmap. Most colormaps allow
*_r
suffix to do this as well.- valuesarray_like[
float
],optional
Lookup table values. Either
values
orcmap
can be set, but not both.- value_range
tuple
,optional
The range of the brightness of the mapped lookup table. This range is only used when creating custom color maps and will be ignored if
cmap
is set.- hue_range
tuple
,optional
Lookup table hue range. This range is only used when creating custom color maps and will be ignored if
cmap
is set.- alpha_range
tuple
,optional
Lookup table alpha (transparency) range. This range is only used when creating custom color maps and will be ignored if
cmap
is set.- scalar_range
tuple
,optional
The range of scalars which will be mapped to colors. Values outside of this range will be colored according to
LookupTable.below_range_color
andLookupTable.above_range_color
.- log_scalebool,
optional
Use a log scale when mapping scalar values.
- nan_color
ColorLike
,optional
Color to render any values that are NANs.
- above_range_color
ColorLike
,optional
Color to render any values above
LookupTable.scalar_range
.- below_range_color
ColorLike
,optional
Color to render any values below
LookupTable.scalar_range
.- ramp
str
,optional
The shape of the table ramp. This range is only used when creating custom color maps and will be ignored if
cmap
is set.- annotations
dict
,optional
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.
- cmap
Examples
Plot the lookup table with the default VTK color map.
>>> import pyvista as pv >>> lut = pv.LookupTable() >>> lut LookupTable (...) Table Range: (0.0, 1.0) N Values: 256 Above Range Color: None Below Range Color: None NAN Color: Color(name='maroon', hex='#800000ff', opacity=255) Log Scale: False Color Map: "PyVista Lookup Table" Alpha Range: (1.0, 1.0) Hue Range: (0.0, 0.66667) Saturation Range (1.0, 1.0) Value Range (1.0, 1.0) Ramp s-curve >>> lut.plot()
Plot the lookup table with the
'inferno'
color map.>>> import pyvista as pv >>> lut = pv.LookupTable('inferno', n_values=32) >>> lut LookupTable (...) Table Range: (0.0, 1.0) N Values: 32 Above Range Color: None Below Range Color: None NAN Color: Color(name='maroon', hex='#800000ff', opacity=255) Log Scale: False Color Map: "inferno" >>> lut.plot()
Methods
LookupTable.apply_cmap
(cmap[, n_values, flip])Assign a colormap to this lookup table.
LookupTable.apply_opacity
(opacity[, ...])Assign custom opacity to this lookup table.
LookupTable.map_value
(value[, opacity])Map a single value through the lookup table, returning an RBG(A) color.
LookupTable.plot
(**kwargs)Plot this lookup table.
Clear the color map and recompute the values table.
Return the VTK color transfer function of this table.
LookupTable.to_opacity_tf
([clamping])Return the opacity transfer function of this table.
Attributes
Return or set the above range color.
Return or set the above range opacity.
Return or set the alpha range.
Return or set annotations.
Return or set the below range color.
Return or set the below range opacity.
Return or set the color map used by this lookup table.
Return or set the hue range.
Use log scale.
Return or set the number of values in the lookup table.
Return or set the not a number (NAN) color.
Return or set the not a number (NAN) opacity.
Set the shape of the table ramp.
Return or set the saturation range.
Return or set the table range.
Return or set the brightness of the mapped lookup table.
Return or set the lookup table values.