https://github.com/callumrollo/cmcrameri
Making Fabio Crameri's perceptually uniform colourmaps for geosciences available on PyPI and conda-forge
https://github.com/callumrollo/cmcrameri
colourmap conda-forge matplotlib pypi python scientific-visualization
Last synced: 17 days ago
JSON representation
Making Fabio Crameri's perceptually uniform colourmaps for geosciences available on PyPI and conda-forge
- Host: GitHub
- URL: https://github.com/callumrollo/cmcrameri
- Owner: callumrollo
- License: other
- Created: 2020-05-06T16:04:02.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2025-05-05T20:08:46.000Z (27 days ago)
- Last Synced: 2025-05-05T21:25:37.574Z (27 days ago)
- Topics: colourmap, conda-forge, matplotlib, pypi, python, scientific-visualization
- Language: Python
- Homepage: http://www.fabiocrameri.ch/colourmaps.php
- Size: 1.33 MB
- Stars: 161
- Watchers: 5
- Forks: 12
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
- Citation: CITATION.cff
Awesome Lists containing this project
README
# cmcrameri
[](https://www.repostatus.org/#active)

 [](https://pepy.tech/project/cmcrameri)
 [](https://anaconda.org/conda-forge/cmcrameri)
This is a Python wrapper around Fabio Crameri's perceptually uniform colormaps.
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](https://doi.org/10.5281/zenodo.8035877) (2023-06-14).
## Install
With `pip`:
```sh
python -m pip install cmcrameri
```With `conda`:
```sh
conda install -c conda-forge cmcrameri
```## Usage example
```python
import cmcrameri.cm as cmc
import matplotlib.pyplot as plt
import numpy as npx = 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`](https://matplotlib.org/stable/api/_as_gen/matplotlib.colors.ListedColormap.html#matplotlib.colors.ListedColormap.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.
```python
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.`.
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:
```python
from cmcrameri import show_cmapsshow_cmaps()
```
The original colormap text files are shipped as part of the package.
Find them on your system with:```python
from cmcrameri.cm import pathspaths
```## License
This work is licensed under an [MIT license](https://mit-license.org/).