Package: cmasher
CMasher: Scientific colormaps for making accessible, informative andcmashingplotsTheCMasherpackage provides a collection of scientific colormaps and utility functions to be used by differentPythonpackages and projects, mainly in combination withmatplotlib, showcased in theonline documentation(where I also describe how to use the colormaps in other languages and applications).
The colormaps inCMasherare all designed to be perceptually uniform sequential using theviscmpackage; 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, likechromaandrainforestforjet;sunburstforhot;neutralforbinary; andfusionandredshiftforcoolwarm.
If you cannot find your ideal colormap, then please open anissue, 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 overviewBelow is an overview of all the colormaps that are currently inCMasher(made with thecmr.create_cmap_overview()function).
For more information, see theonline documentation.In the figure, one can see this wide range of color combinations thatCMasherhas to offer, as I wanted to make sure thatCMasherhas a colormap for everyone.
Because of this,CMasher’s sequential colormaps range from single major color maps likeamber;ember;flamingo;freeze;gothic; andjungle, to colormaps with high perceptual ranges likeapple;chroma;torch;neon; andrainforest.
The diverging colormaps inCMasherhave a similar variety, but more importantly, several of them have a black center instead of a white center, likeiceburn;redshift;watermelon; andwildfire.
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 & UseHow to installCMashercan be easily installed directly fromPyPIwith:$ pip install cmasheror fromconda-forgewith:$ 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 channelIf required, one can also clone therepositoryand installCMashermanually:$ git clone https://github.com/1313e/CMasher
$ cd CMasher
$ pip install .CMashercan now be imported as a package withimport 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 supportCMashercan be found in the online documentationhere.Example useThe colormaps shown above can be accessed by simply importingCMasher.
This makes them available in thecmashermodule, in addition to registering them inmatplotlib’scmmodule (with added'cmr.'prefix to avoid name clashes).
So, for example, if one were to use therainforestcolormap, this could be done with:# Import CMasher to register colormapsimportcmasherascmr# Import packages for plottingimportmatplotlibasmplimportmatplotlib.pyplotaspltimportnumpyasnp# Access rainforest colormap through CMasher or MPLcmap=cmr.rainforest# CMashercmap=mpl.colormaps['cmr.rainforest']# MPL# Generate some data to plotx=np.random.rand(100)y=np.random.rand(100)z=x**2+y**2# Make scatter plot of data with colormapplt.scatter(x,y,c=z,cmap=cmap,s=300)plt.show()For other use-cases, including an overview ofCMasher’s utility functions and how to useCMasherin other programming languages and applications, see theonline documentation.