alphapepttools.pl.BaseColormaps#

class alphapepttools.pl.BaseColormaps#

Continuous colormaps for alphapepttools plots

Provides access to perceptually uniform colormaps optimized for continuous data visualization. Uses cmcrameri colormaps to avoid visual distortion (Crameri, F. (2018a), Scientific colour maps. Zenodo. http://doi.org/10.5281/zenodo.1243862).

Attributes table#

Methods table#

get(colormap_name[, n])

Retrieve a colormap by name or sample discrete colors from it

Attributes#

BaseColormaps.default_colormaps: ClassVar[dict] = {'diverging': <matplotlib.colors.ListedColormap object>, 'diverging_r': <matplotlib.colors.ListedColormap object>, 'magma_clipped': <matplotlib.colors.LinearSegmentedColormap object>, 'sequential': <matplotlib.colors.ListedColormap object>, 'sequential_clipped': <matplotlib.colors.LinearSegmentedColormap object>, 'sequential_r': <matplotlib.colors.ListedColormap object>, 'sequential_r_clipped': <matplotlib.colors.LinearSegmentedColormap object>}#

Methods#

classmethod BaseColormaps.get(colormap_name, n=None)#

Retrieve a colormap by name or sample discrete colors from it

Retrieves colormaps from the default colormap collection or matplotlib. Can return either the full continuous colormap or a discrete set of n evenly-spaced colors sampled from it.

Parameters:
  • colormap_name (str) – Name of colormap from default_colormaps or matplotlib colormap name.

  • n (int, optional) – Number of discrete colors to sample from the colormap. If None, returns the full continuous colormap object.

Return type:

Colormap | list

Returns:

Colormap | list If n is None, returns matplotlib Colormap object. If n is specified, returns list of n RGBA color tuples sampled evenly from the colormap.

Examples

Get a full colormap for continuous data:

from alphapepttools.pl.colors import BaseColormaps

cmap = BaseColormaps.get("sequential")
# Returns continuous colormap object for use with imshow, contourf, etc.

Sample discrete colors from a colormap:

colors = BaseColormaps.get("sequential", n=5)
# Returns 5 evenly-spaced RGBA colors from sequential colormap

Use a diverging colormap:

cmap = BaseColormaps.get("diverging")
# Returns diverging colormap centered at midpoint

Get clipped colormap to avoid extreme colors:

cmap = BaseColormaps.get("sequential_clipped")
# Returns sequential colormap with darkest 20% removed