$ show 1313e/CMasher
CMasher is a Python library that provides 60+ scientific colormaps for Matplotlib, designed for perceptual uniformity and color-vision-deficiency accessibility. At runtime, importing cmasher registers every colormap into Matplotlib's colormap registry under a `cmr.` prefix, exposing forward, reversed, and for cyclic maps half-shifted variants. The package also ships a CLI (`cmr`), utility functions for combining, sub-selecting, sampling, viewing, and exporting colormaps, plus cross-application exporters for Tableau and R. The colormap definitions themselves are stored as static NumPy arrays, normalized/8-bit/hex text files, JSON `.jscm` files, and generated Python modules, making the project both a functional library and a curated data asset.
The LLM identified 4 files worth highlighting for reuse:
Core utility hub implementing colormap import/export, registration, sub-colormap extraction, colormap combination, color sampling, overview-figure generation, and perceptual ranking via CAM02-UCS. The individual algorithmsβespecially take_cmap_colors, combine_cmaps, get_sub_cmap, and create_cmap_modβare generalized enough to be extracted into standalone visualization tooling.
A custom Matplotlib legend handler for PolyCollection-based color artists, enabling gradient/colormap swatches to appear in legends. It is isolated from the rest of the package and can be reused in any Matplotlib project needing legend entries for non-standard artists.
Generates Tableau preferences files from CMasher colormap definitions, allowing the scientific colormaps to be used outside Python. This is a clean cross-application serialization pattern and could be adapted to export standardized colormap data to other tools.
Provides the `cmr` command-line interface with subcommands for listing colormaps, viewing them, extracting colors, generating standalone colormap modules, and exporting to Tableau. It offers a compact, extensible model for building scientific-tooling CLIs on top of a Python library.