Registry / data / colorcet

colorcet

JSON →
library3.2.1pypypi✓ verified 24d ago

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 colorcet
INSTALL
IMPORT
SIG · COLORCET
C
colorcet
datapythonv3.2.1
Install
1.8s avg
Import
9923ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.2.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 10.380s · 19.6MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 9.466s · 20MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

colorcet
import colorcet as cc
The common and recommended alias for Colorcet.
continuous_colormap
cc.cm.fire
cc.fire (for Matplotlib directly)
For Matplotlib `cmap` arguments, access colormaps via `cc.cm.<name>`. `cc.<name>` directly provides the Bokeh-style hex list palette. Matplotlib also registers colormaps under names like `cet_<name>` (e.g., `plt.get_cmap('cet_fire')`).
categorical_palette
cc.glasbey
cc.cm.glasbey (for Bokeh-style hex list)
Access hex-string palettes directly as `cc.<name>` or `cc.palette.<name>`. For Matplotlib, these might need to be wrapped in `matplotlib.colors.ListedColormap` for some plotting functions.

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.

import numpy as np import matplotlib.pyplot as plt import colorcet as cc # Create some dummy data xs, _ = np.meshgrid(np.linspace(0, 1, 80), np.linspace(0, 1, 10)) # Use a continuous colormap from colorcet with Matplotlib plt.figure(figsize=(8, 1)) plt.imshow(xs, cmap=cc.cm.fire, aspect='auto') plt.title('Using colorcet.cm.fire') plt.axis('off') plt.show() # Example of a categorical palette (prints hex codes) print(f"First 5 colors of glasbey palette: {cc.glasbey[:5]}")
Debug
Known issues
breakingThe `colorcet examples` command-line interface (CLI) was removed in version 3.1.0.
fix
Refer to the official documentation and GitHub examples for usage demonstrations and plotting commands, rather than the removed CLI.
affects: >=3.1.0
breakingSupport for Python 2.7 and 3.6 was officially dropped in version 3.1.0. Older Python versions are no longer tested or maintained.
fix
Upgrade your Python environment to 3.7 or newer. Python 3.7+ is supported, with 3.9+ being recommended by some sources.
affects: >=3.1.0
deprecatedThe `inferno` colormap was renamed to `bmy` in version 1.0.0 to avoid confusion with Matplotlib's built-in `inferno`.
fix
If migrating from pre-1.0.0 code using `inferno`, update calls to `bmy`. For new code, use `bmy` directly.
affects: >=1.0.0
gotchaColorcet colormaps can be accessed in several ways: `cc.cm.<name>` (Matplotlib colormap object), `cc.palette.<name>` or `cc.<name>` (Bokeh-style hex string list), or via Matplotlib's registry using names like `cet_<name>` (e.g., `plt.get_cmap('cet_fire')`). Choosing the correct access method depends on the plotting library and desired output format.
fix
Consult the User Guide for detailed explanations on accessing continuous and categorical colormaps in different formats for various plotting backends.
affects: All
gotchaWhile Colorcet's continuous colormaps are perceptually uniform, its categorical colormaps are perceptually *distinct* but not necessarily uniform. Also, not all colormaps are guaranteed to be colorblind-safe or perceptually uniform in their monochrome representation, unlike some Matplotlib-native colormaps.
fix
For scientific visualization, understand the characteristics of the chosen colormap (continuous vs. categorical, colorblind safety) and verify its suitability for your data and audience.
affects: All
gotchaThe functions in `colorcet.plotting` (e.g., `swatch`, `swatches`) require `holoviews` to be installed and the appropriate `holoviews` extension loaded (e.g., `hv.extension('matplotlib')` or `hv.extension('bokeh')`).
fix
Install `holoviews` (`pip install holoviews`) and ensure the correct `hv.extension()` is called before using `colorcet.plotting` functions.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'colorcet'
The colorcet library is not installed in the Python environment.
fix
Install colorcet using pip: `pip install colorcet` or conda: `conda install colorcet`.
AttributeError: module 'colorcet' has no attribute 'cm'
This error occurs when trying to access Matplotlib colormaps using `cc.cm.<colormap_name>`, which is an outdated or incorrect way. Matplotlib colormaps are directly available as `cc.m_<colormap_name>` or registered with Matplotlib's string-based dictionary using the `cet_` prefix.
fix
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'`).
ValueError: A colormap named "cet_gray" is already registered
This error happens when multiple libraries (e.g., colorcet and ArviZ) attempt to register a colormap with the same name (like 'cet_gray') in Matplotlib's colormap registry, leading to a conflict.
fix
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.
ValueError: [[0, 0.20387, 0.96251], ...] is not a valid value for name; supported values are 'Accent', ...
This error occurs when a user tries to pass a Bokeh-style palette (which is a list of RGB color values) directly to a Matplotlib function that expects a Matplotlib colormap object or a registered colormap name.
fix
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.
Upgrade
Version history
3.2.1latest on PyPI · released Apr 28, 2026
Audit
Dependencies
pythonrequiredColorcet officially supports Python 3.7 and greater.
matplotliboptionalRequired for using Colorcet colormaps directly with Matplotlib's API (e.g., `plt.imshow(cmap=cc.cm.colormap_name)`).
holoviewsoptionalRequired for using the `colorcet.plotting.swatch` and `swatches` functions to visualize colormaps.
Agent activity
40 hits · last 30 days
node
34
OpenAI (training)
1
Resources