pyvista.CompositePolyDataMapper.set_unique_colors

pyvista.CompositePolyDataMapper.set_unique_colors#

CompositePolyDataMapper.set_unique_colors(
color_cycler: bool | str | cycler.Cycler[str, ColorLike] | Sequence[ColorLike] = True,
)[source]#

Set each block of the dataset to a unique color.

This uses matplotlib’s color cycler by default.

When a custom color cycler, or a sequence of color-like objects, is passed it sets the blocks to the corresponding colors.

Parameters:
color_cyclerbool | str | cycler.Cycler | sequence[ColorLike]

The sequence of colors to cycle through, if True, uses matplotlib cycler.

Examples

Set each block of the composite dataset to a unique color.

>>> import pyvista as pv
>>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))])
>>> pl = pv.Plotter()
>>> actor, mapper = pl.add_composite(dataset)
>>> mapper.set_unique_colors()
>>> mapper.block_attr[1].color
Color(name='tab:orange', hex='#ff7f0eff', opacity=255)
>>> mapper.block_attr[2].color
Color(name='tab:green', hex='#2ca02cff', opacity=255)
../../../_images/pyvista-CompositePolyDataMapper-set_unique_colors-1_00_00.png