pyvista.LookupTable.apply_cmap#

LookupTable.apply_cmap(cmap, n_values: int = 256, flip: bool = False)[source]#

Assign a colormap to this lookup table.

This can be used instead of LookupTable.cmap when you need to set the number of values at the same time as the color map.

Parameters:
cmapstr, list, colors.Colormap

Colormap from Matplotlib, colorcet, or cmocean.

n_valuesint, default: 256

Number of colors in the color map.

flipbool, default: False

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

Examples

Apply matplotlib’s 'cividis' color map.

>>> import pyvista as pv
>>> lut = pv.LookupTable()
>>> lut.apply_cmap('cividis', n_values=32)
>>> lut.plot()
../../../_images/pyvista-LookupTable-apply_cmap-1_00_00.png