Colorcet is a collection of perceptually uniform and distinct colormaps for use with Python plotting programs like Matplotlib, Bokeh, HoloViews, and Datashader. It provides 256-color continuous colormaps based on Peter Kovesi's work and perceptually distinct categorical colormaps. The library is actively maintained, with the current version being 3.1.0, and receives updates for new colormaps and compatibility with the Python ecosystem.
pip install colorcetVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import `colorcet` and apply one of its continuous colormaps to a Matplotlib plot. It also shows how to access a categorical palette as a list of hex strings.
Refer to the official documentation and GitHub examples for usage demonstrations and plotting commands, rather than the removed CLI.
Upgrade your Python environment to 3.7 or newer. Python 3.7+ is supported, with 3.9+ being recommended by some sources.
If migrating from pre-1.0.0 code using `inferno`, update calls to `bmy`. For new code, use `bmy` directly.
Consult the User Guide for detailed explanations on accessing continuous and categorical colormaps in different formats for various plotting backends.
For scientific visualization, understand the characteristics of the chosen colormap (continuous vs. categorical, colorblind safety) and verify its suitability for your data and audience.
Install `holoviews` (`pip install holoviews`) and ensure the correct `hv.extension()` is called before using `colorcet.plotting` functions.
Install colorcet using pip: `pip install colorcet` or conda: `conda install colorcet`.
Access Matplotlib colormaps as `cc.m_<colormap_name>` (e.g., `cc.m_fire`) or use the string name directly with Matplotlib functions after importing colorcet (e.g., `cmap='cet_fire'`).
The solution often involves ensuring that only one library registers the conflicting colormap, or checking if the colormap is already registered before attempting to register it. In practice, updating both libraries to their latest versions might resolve conflicts as they may have implemented checks. Otherwise, explicitly importing colorcet first or using its prefixed names (e.g., `cc.m_gray`) can sometimes work. If ArviZ is the intended source, it might be necessary to disable colorcet's registration or vice-versa, depending on desired behavior.
Convert the Bokeh-style palette to a Matplotlib `ListedColormap` or access the Matplotlib-specific colormap from colorcet using the `cc.m_` prefix. For categorical maps, use `from matplotlib.colors import ListedColormap; cmap = ListedColormap(cc.<palette_name>)` (e.g., `cmap = ListedColormap(cc.glasbey)`) or directly use `cc.m_<colormap_name>` if a Matplotlib version is available.