napari.utils.DirectLabelColormap#

class napari.utils.DirectLabelColormap(*args, colors: ColorArray, name: str = 'custom', interpolation: Literal[ColormapInterpolationMode.ZERO] = ColormapInterpolationMode.ZERO, controls: Array = None, use_selection: bool = False, selection: int = 0, background_value: int = 0, color_dict: defaultdict[int | None, ndarray] = None)[source]#

Bases: LabelColormapBase

Colormap using a direct mapping from labels to color using a dict.

color_dict#

The dictionary mapping labels to colors.

Type:

dict from int to (3,) or (4,) array

use_selection#

Whether to map only the selected label to a color. If True only selected label will be not transparent.

Type:

bool

selection#

The selected label.

Type:

int

colors#

Exist because of implementation details. Please do not use it.

Type:

ColorArray

Inherited-members:

Methods

construct([_fields_set])

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data.

copy(*[, include, exclude, update, deep])

Duplicate a model, optionally choose which fields to include, exclude and change.

dict(*[, include, exclude, by_alias, ...])

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

enums_as_values([as_values])

Temporarily override how enums are retrieved.

from_orm(obj)

json(*[, include, exclude, by_alias, ...])

Generate a JSON representation of the model, include and exclude arguments as per dict().

map(values)

Map values to colors.

parse_file(path, *[, content_type, ...])

parse_obj(obj)

parse_raw(b, *[, content_type, encoding, ...])

reset()

Reset the state of the model to default values.

schema([by_alias, ref_template])

schema_json(*[, by_alias, ref_template])

update(values[, recurse])

Update a model in place.

update_forward_refs(**localns)

Try to update ForwardRefs on fields based on this Model, globalns and localns.

validate(value)

Attributes

colorbar

default_color

events

Details

map(values: ndarray | integer | int) ndarray[source]#

Map values to colors.

Parameters:

values (np.ndarray or int) – Values to be mapped.

Returns:

Mapped colors.

Return type:

np.ndarray of same shape as values, but with last dimension of size 4