Skip to content

Making Fabio Crameri's perceptually uniform colourmaps for geosciences available on PyPI and conda-forge

License

Notifications You must be signed in to change notification settings

callumrollo/cmcrameri

Folders and files

NameName
Last commit message
Last commit date
Jan 15, 2025
Jan 29, 2024
Feb 5, 2024
Mar 14, 2023
Mar 4, 2025
Oct 22, 2024
Nov 8, 2021
Mar 14, 2023
Sep 11, 2022
Mar 14, 2023
Jan 27, 2025
Nov 5, 2024
Mar 14, 2023

Repository files navigation

cmcrameri

Project Status: Active – The project has reached a stable, usable state and is being actively developed.

python versions

pypi Downloads

anaconda badge Conda Downloads

This is a Python wrapper around Fabio Crameri's perceptually uniform colormaps.

https://www.fabiocrameri.ch/colourmaps/

All credit for creating the colormaps to Fabio. Any errors in the Python implementation of colormaps are my own.

This version is based on Scientific colour maps version 8.0 (2023-06-14).

Install

With pip:

python -m pip install cmcrameri

With conda:

conda install -c conda-forge cmcrameri

Usage example

import cmcrameri.cm as cmc
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 1, 100)[np.newaxis, :]

plt.imshow(x, aspect='auto', cmap=cmc.batlow)
plt.axis('off')
plt.show()

For a discretized colormap like batlow split into 25 levels, you can use the .resampled method on any of the colormaps:

plt.imshow(x, aspect='auto', cmap=cmc.batlow.resampled(25))

Alternatively, the registered name string can be used.

import cmcrameri # required in order to register the colormaps with Matplotlib
...
plt.imshow(x, aspect='auto', cmap='cmc.batlow')

Extra instructions

You can access all the core colormaps from Fabio Crameri's list by cmcrameri.cm.<colormapname>.

You can use tab autocompletion on cmcrameri.cm if your editor supports it.

For a reversed colormap, append _r to the colormap name.

Categorical colormaps have the suffix S.

For an image of all the available colormaps without leaving the comfort of your Python session:

from cmcrameri import show_cmaps

show_cmaps()

Figure demonstrating the colormaps

The original colormap text files are shipped as part of the package. Find them on your system with:

from cmcrameri.cm import paths

paths

License

This work is licensed under an MIT license.

About

Making Fabio Crameri's perceptually uniform colourmaps for geosciences available on PyPI and conda-forge

Topics

Resources

License

Citation

Stars

Watchers

Forks

Packages

No packages published

Languages