Scientific colormaps for making accessible, informative and 'cmashing' plots
Project description
CMasher: Scientific colormaps for making accessible, informative and cmashing plots
The CMasher package provides a collection of scientific colormaps and utility functions to be used by different Python packages and projects, mainly in combination with matplotlib, showcased in the online documentation (where I also describe how to use the colormaps in other languages and applications). The colormaps in CMasher are all designed to be perceptually uniform sequential using the viscm package; most of them are color-vision deficiency friendly; and they cover a wide range of different color combinations to accommodate for most applications. It offers several alternatives to commonly used colormaps, like chroma and rainforest for jet; sunburst for hot; neutral for binary; and fusion and redshift for coolwarm. If you cannot find your ideal colormap, then please open an issue, provide the colors and/or style you want, and I will try to create one to your liking! Let’s get rid of all bad colormaps in the world together!
If you use CMasher for your work, then please star the repo, such that I can keep track of how many users it has and more easily raise awareness of bad colormaps. Additionally, if you use CMasher as part of your workflow in a scientific publication, please consider citing the CMasher paper (BibTeX: cmr.get_bibtex).
Colormap overview
Below is an overview of all the colormaps that are currently in CMasher (made with the cmr.create_cmap_overview() function). For more information, see the online documentation.
In the figure, one can see this wide range of color combinations that CMasher has to offer, as I wanted to make sure that CMasher has a colormap for everyone. Because of this, CMasher’s sequential colormaps range from single major color maps like amber; ember; flamingo; freeze; gothic; and jungle, to colormaps with high perceptual ranges like apple; chroma; torch; neon; and rainforest. The diverging colormaps in CMasher have a similar variety, but more importantly, several of them have a black center instead of a white center, like iceburn; redshift; watermelon; and wildfire. Black centered diverging colormaps are quite rare as most researchers are used to white centered ones, even though a black centered diverging colormap can be rather useful in certain cases, like plotting a radial velocity map (the further away from the common center, the higher the velocity in either direction, and thus the corresponding color should be brighter).
Installation & Use
How to install
CMasher can be easily installed directly from PyPI with:
$ pip install cmasher
or from conda-forge with:
$ conda install -c conda-forge cmasher # If conda-forge is not set up as a channel $ conda install cmasher # If conda-forge is set up as a channel
If required, one can also clone the repository and install CMasher manually:
$ git clone https://github.com/1313e/CMasher $ cd CMasher $ pip install .
CMasher can now be imported as a package with import cmasher as cmr.
Besides Python, CMasher’s colormaps can also be accessed in various other languages and applications. A list of all currently known languages and applications that support CMasher can be found in the online documentation here.
Example use
The colormaps shown above can be accessed by simply importing CMasher. This makes them available in the cmasher module, in addition to registering them in matplotlib’s cm module (with added 'cmr.' prefix to avoid name clashes). So, for example, if one were to use the rainforest colormap, this could be done with:
# Import CMasher to register colormaps
import cmasher as cmr
# Import packages for plotting
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
# Access rainforest colormap through CMasher or MPL
cmap = cmr.rainforest # CMasher
cmap = mpl.colormaps['cmr.rainforest'] # MPL
# Generate some data to plot
x = np.random.rand(100)
y = np.random.rand(100)
z = x**2+y**2
# Make scatter plot of data with colormap
plt.scatter(x, y, c=z, cmap=cmap, s=300)
plt.show()
For other use-cases, including an overview of CMasher’s utility functions and how to use CMasher in other programming languages and applications, see the online documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cmasher-1.9.1.tar.gz
.
File metadata
- Download URL: cmasher-1.9.1.tar.gz
- Upload date:
- Size: 50.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | edb0b2fd224db305cffbb40932a091212d198db697e712e774b1f6156dbca4f6 |
|
MD5 | d32d813c7db1257e5293279b4b612d1a |
|
BLAKE2b-256 | f6a2beb240e84976be6bb8ca156abdddf515924fc558150d34ccdd2296ddd82b |
Provenance
The following attestation bundles were made for cmasher-1.9.1.tar.gz
:
Publisher:
test.yml
on 1313e/CMasher
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
cmasher-1.9.1.tar.gz
- Subject digest:
edb0b2fd224db305cffbb40932a091212d198db697e712e774b1f6156dbca4f6
- Sigstore transparency entry: 149737490
- Sigstore integration time:
- Predicate type:
File details
Details for the file cmasher-1.9.1-py3-none-any.whl
.
File metadata
- Download URL: cmasher-1.9.1-py3-none-any.whl
- Upload date:
- Size: 37.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c5b35336b90591361d8c765abb7c5cba46448e1b4dbf59d0e5116f89fef0ceb |
|
MD5 | 182da4d52e09078bef46e58b4245b130 |
|
BLAKE2b-256 | f9dc0c6acd95479edcb151c1ed352fe3d92c7beb9f693f4eaa643d5d50e57d02 |
Provenance
The following attestation bundles were made for cmasher-1.9.1-py3-none-any.whl
:
Publisher:
test.yml
on 1313e/CMasher
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
cmasher-1.9.1-py3-none-any.whl
- Subject digest:
9c5b35336b90591361d8c765abb7c5cba46448e1b4dbf59d0e5116f89fef0ceb
- Sigstore transparency entry: 149737493
- Sigstore integration time:
- Predicate type: