pyvista.LookupTable

Contents

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,
)[source]#

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:
cmapstr | colors.Colormap, optional

Color map from matplotlib, colorcet, or cmocean. Either cmap or values can be set, but not both.

n_valuesint, 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 or cmap can be set, but not both.

value_rangetuple, 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_rangetuple, optional

Lookup table hue range. This range is only used when creating custom color maps and will be ignored if cmap is set.

alpha_rangetuple, 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_rangetuple, 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 and LookupTable.above_range_color.

log_scalebool, optional

Use a log scale when mapping scalar values.

nan_colorColorLike, optional

Color to render any values that are NANs.

above_range_colorColorLike, optional

Color to render any values above LookupTable.scalar_range.

below_range_colorColorLike, optional

Color to render any values below LookupTable.scalar_range.

rampstr, 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.

annotationsdict, 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.

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()
../../../_images/pyvista-LookupTable-1_00_00.png

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()
../../../_images/pyvista-LookupTable-1_01_00.png

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.

LookupTable.rebuild()

Clear the color map and recompute the values table.

LookupTable.to_color_tf()

Return the VTK color transfer function of this table.

LookupTable.to_opacity_tf([clamping])

Return the opacity transfer function of this table.

Attributes

LookupTable.above_range_color

Return or set the above range color.

LookupTable.above_range_opacity

Return or set the above range opacity.

LookupTable.alpha_range

Return or set the alpha range.

LookupTable.annotations

Return or set annotations.

LookupTable.below_range_color

Return or set the below range color.

LookupTable.below_range_opacity

Return or set the below range opacity.

LookupTable.cmap

Return or set the color map used by this lookup table.

LookupTable.hue_range

Return or set the hue range.

LookupTable.log_scale

Use log scale.

LookupTable.n_values

Return or set the number of values in the lookup table.

LookupTable.nan_color

Return or set the not a number (NAN) color.

LookupTable.nan_opacity

Return or set the not a number (NAN) opacity.

LookupTable.ramp

Set the shape of the table ramp.

LookupTable.saturation_range

Return or set the saturation range.

LookupTable.scalar_range

Return or set the table range.

LookupTable.value_range

Return or set the brightness of the mapped lookup table.

LookupTable.values

Return or set the lookup table values.