class DiscreteColormap(colors, name=None, N=None, alpha=None, **kwargs)[source]

Bases: ListedColormap, _Colormap

Replacement for ListedColormap.

  • colors (sequence of color-spec, optional) – The colormap colors.

  • name (str, default: '_no_name') – The colormap name.

  • N (int, default: len(colors)) – The number of levels. The color list is truncated or wrapped to match this length.

  • alpha (float, optional) – The opacity for the colormap colors. This overrides the input color opacities.

Other Parameters

**kwargs – Passed to ListedColormap.

Methods Summary

append(*args[, name, N])

Append arbitrary colormaps onto this colormap.

copy([colors, name, N, alpha])

Return a new colormap with relevant properties copied from this one if they were not provided as keyword arguments.

from_file(path, *[, warn_on_failure])

Load color cycle from a file.


Return a reversed version of the colormap.

save([path, alpha])

Save the colormap data to a file.


Set the opacity for the entire colormap.

shifted([shift, name])

Return a cyclically shifted version of the colormap.

truncate([left, right, name])

Return a truncated version of the colormap.