Skip to main content

Scientific colormaps for making accessible, informative and 'cmashing' plots

Project description

PyPI - Latest Release Conda-Forge - Latest Release PyPI - Python Versions GitHub Actions - Build Status CodeCov - Coverage Status JOSS - Submission Status

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). 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.

CMasher Colormap Overview

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; heat; 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.

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.pyplot as plt
import numpy as np

# Access rainforest colormap through CMasher or MPL
cmap = cmr.rainforest                   # CMasher
cmap = plt.get_cmap('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, see the online documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmasher-1.5.10.tar.gz (282.7 kB view details)

Uploaded Source

Built Distribution

cmasher-1.5.10-py3-none-any.whl (293.2 kB view details)

Uploaded Python 3

File details

Details for the file cmasher-1.5.10.tar.gz.

File metadata

  • Download URL: cmasher-1.5.10.tar.gz
  • Upload date:
  • Size: 282.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.7.9

File hashes

Hashes for cmasher-1.5.10.tar.gz
Algorithm Hash digest
SHA256 b1cdc5c9e9a7fbd4a5647056dbbeac90920fbf28102e14e0d731bee38c8c12e5
MD5 af92a865359fc1494f1bf089652a794e
BLAKE2b-256 97645ce30cbf1bdcbb5f471b2d5c07908ef858d2670eb28350f7df7da9b59b30

See more details on using hashes here.

File details

Details for the file cmasher-1.5.10-py3-none-any.whl.

File metadata

  • Download URL: cmasher-1.5.10-py3-none-any.whl
  • Upload date:
  • Size: 293.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.7.9

File hashes

Hashes for cmasher-1.5.10-py3-none-any.whl
Algorithm Hash digest
SHA256 0d7320a5b570a109dd15e670c63bd2a7009992e92cdd36a0d0f337d955f5acfe
MD5 f7706a5e5e3a467e7740a09cf2d6c4bb
BLAKE2b-256 c81a9d110372f9de144aa3bc7883b4128a6f8865a28436bac57147e6d9b30ba2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page