cmap provides a collection of scientific colormaps for Python, focusing on perceptual uniformity and colorblind-friendliness. It bundles various colormaps like Crameri, Tol, Viridis, and many others, offering a unified API to access and manipulate them. The library is actively maintained with frequent minor releases, currently at version 0.7.2.
pip install cmapVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to fetch a colormap using `get_cmap`, convert data to RGBA colors, and integrate the `cmap` colormap with Matplotlib for visualization via the `to_mpl()` method.
Upgrade to Python 3.9 or newer (e.g., `python -m pip install --upgrade python` or update your environment).
Review any code that depends on exact `crameri` color values when upgrading from versions prior to 0.5.0. Consider pinning `cmap<0.5.0` if strict adherence to old `crameri` maps is required.
Always use `get_cmap("name")` for general access, or explicitly specify the namespace like `Colormap.scientific.viridis` when you know the colormap's location.Consult the documentation for the specific colormap to understand its required parameters. For example, `my_parametrized_cmap = Colormap.get_cmap('my_param_map', arg1=value1, arg2=value2)` or `Colormap.linear_segmented(colors=['red', 'blue'])`.Use `from cmap import get_cmap; my_cmap = get_cmap('my_colormap_name')` or access through its specific namespace, e.g., `from cmap import Colormap; my_cmap = Colormap.scientific.my_colormap_name`.Ensure `matplotlib` is correctly installed in your environment: `pip install matplotlib` or `pip install cmap` without `--no-deps`.
Check the colormap's documentation or source for expected parameters. Pass the required keyword arguments, e.g., `get_cmap('my_parametrized_colormap', segment_colors=['red', 'green', 'blue'])`.