perfect-cmaps
Create amazing perceptually uniform colormaps with ease!
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.2%) to scientific vocabulary
Keywords
Repository
Create amazing perceptually uniform colormaps with ease!
Basic Info
Statistics
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
perfect-cmaps
This package provides Python functionality for creating custom colormaps which are perfectly perceptually uniform.
The project came up as a result of there being too few easily accessible perceptually uniform colormaps, so I wanted to have a go at creating a good library where users can easily create their own. I wasn't quite happy with colormaps such as viridis, plasma or magma from matplotlib, so I started making some algorithmic colormaps.
To stay as true as possible to the lightness achieved by a true grayscale colormap, but add more information with colors, the perceptual range of colormaps is optimized to be as high as possible.
Main package functionality
create_cmap(): Create your own colormap.get_cmap(): Get a named colormap from the library -- an instance ofmatplotlib.colors.LinearSegmentedColormap.list_cmaps(): Lists all available local and internal colormaps.compare_cmaps(): Plots a comparison of given colormaps by names.
Example of creating a custom colormap
run: python ./perfect_cmaps/customize_cmap.py --num_points 21 --lightness linear or a similar command
This specifies that your colormap will have 21 control points, which will later be interpolated for desired granularity, and that the colormap will have a linear lightness profile.
https://github.com/user-attachments/assets/a63d0c31-d799-49d0-a2cd-30c0b423378f
Generated colormap
To test out your colormap, you can use the function get_cmap() or use the main function from colormaps.py:
python ./perfect_cmaps/colormaps.py --colormap test_colormap -n 1000 --interpolation quadratic --smoothing 0.03
Here' the colormap was named test_colormap, and we specify the colormap to have 1000 points, with quadratic interpolation and some amount of smoothing applied.

Test images

Here's a compilation of some colormaps generated with this library, compared with some standard colormaps available in matplotlib:

The top two colormaps, viridis and cividis have a lower perceptual range, and thus look less clear -- almost like there's a filter on them. The colormaps generated with perfect-cmaps are crisper and offer a maximal perceptual range. Additionally, the perceptual limitation for the standard colormaps is especially visible when for example a background in grayscale is very white, in which case the standard colormaps are in this case yellow and clearly do not cover the entire lightness spectrum.

The algorithmically created ectotherm colormap in fact covers 100 % of the perceptual range, while adding more information through colors. It ranges from completely black to completely white, while adding colors in between and maintaining truly linearly increasing lightness. This is one of my favorites! The other two displayed custom colormaps mimic viridis and cividis, but with a higher perceptual range. The standard ectotherm colormap is linear in luminance, whereas the ectotherm_l colormap is linear in lightness. I recommend the ectotherm_l colormap for general use.

You may have heard that standard RGB colormaps should be avoided. Well, common RGB colormaps are indeed not at all perceptually uniform, but if you design them right, you can still have a useful colormap with much color information, perceptual range and true perceptual uniformity.

Thanks to Nanoscience.com for letting me use the grayscale images as examples! Find them at https://www.nanoscience.com/techniques/scanning-electron-microscopy/.
These custom generated colormaps are theoretically perceptually uniform, but note that some screen settings may show colormap artifacts, making the colormaps appear less perceptually uniform. This may happen at lower computer screen lighting, for example.
Owner
- Name: Mattias Ulmestrand
- Login: m-ulmestrand
- Kind: user
- Location: Gothenburg, Sweden
- Repositories: 3
- Profile: https://github.com/m-ulmestrand
Hi, I'm Mattias. I do a lot of AI. I'm especially interested in applying Machine Learning for physics and games, or optimally, a combination of both.
GitHub Events
Total
- Issues event: 5
- Watch event: 5
- Delete event: 4
- Issue comment event: 5
- Push event: 88
- Create event: 5
Last Year
- Issues event: 5
- Watch event: 5
- Delete event: 4
- Issue comment event: 5
- Push event: 88
- Create event: 5
Packages
- Total packages: 1
-
Total downloads:
- pypi 198 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 12
- Total maintainers: 1
pypi.org: perfect-cmaps
Create amazing perceptually uniform colormaps with ease!
- Homepage: https://github.com/m-ulmestrand/perfect-cmaps
- Documentation: https://perfect-cmaps.readthedocs.io/
- License: Apache Software License
-
Latest release: 1.4.0
published 8 months ago