playnano.utils.colormaps module¶
playNano’s colormaps, and helpers for checking colormap names.
Importing playnano registers the colormaps "afm_brown" (the
default), "playnano_gold" and "classic_afm", each with a reversed
"_r" version, so they can be used by name anywhere in Matplotlib.
- playnano.utils.colormaps.get_available_cmaps() list[str][source]¶
Return the names of all registered colormaps, sorted.
- playnano.utils.colormaps.is_valid_cmap(name: str) bool[source]¶
Check whether a name is a registered Matplotlib colormap.
- playnano.utils.colormaps.register_custom_colormaps() None[source]¶
Register playNano’s colormaps with Matplotlib.
Reads
afm_brown,playnano_goldandclassic_afmfrom the package’sresources/colormapsfolder and registers each, with its reversed_rversion. Colormaps already registered are skipped, so it is safe to call again. A colormap that fails to load is logged as an error and the others are still registered.
- playnano.utils.colormaps.resolve_cmap(cmap: str) str[source]¶
Return a colormap name that can be used, falling back to the default.
For names given by users, for example on the command line: an unknown name gives a logged warning and
"afm_brown"(DEFAULT_CMAP) instead of an error.- Parameters:
cmap (str) – Requested colormap name.
- Returns:
cmapif it is a registered colormap, otherwise"afm_brown".- Return type:
See also
is_valid_cmapCheck a name without a fallback.
Examples
>>> from playnano.utils.colormaps import resolve_cmap >>> resolve_cmap("viridis") 'viridis' >>> resolve_cmap("not_a_colormap") 'afm_brown'