epygram.colormapping — Custom colormaps reading and tuning.

Custom colormaps reading and tuning.


class epygram.colormapping.ColormapHelper(colormap, explicit_colorbounds=None, normalize=False, explicit_ticks=None)[source]

Bases: object

An integrated object helping for colormapping.

A ColormapHelper is meant to help dealing with colormapping, especially mapping values to color changes, and prepares colormapping arguments for plotting functions.

Parameters
  • colormap – name of the colormap to be used

  • explicit_colorbounds – to specify explicitly the colorbounds, i.e. values where colors need to change. Includes min value as first item, and max value as last item.

  • normalize – if colors need to be normalized, i.e. that each color interval need to occupy the same space on the colorbar.

  • explicit_ticks – to specify the ticks values to be shown

colorbounds(minmax=None, number=None, step=None)[source]

Get color bounds, i.e. values where colors change. Arguments are needed for implicit colorbounds only.

Parameters
  • minmax – (min, max) values of the values to be plotted

  • number – number of different colors

  • step – step in values from min to max, where to change colors

Arguments number and step are mutually exclusive.

kwargs_for_plot(plot_method, minmax=None, center_cmap_on_0=False, **colorbounds_kw)[source]

Get kwargs for plot.

Parameters
  • plot_method – because arguments depend on plotting method.

  • minmax – min and max values to be plot.

  • center_cmap_on_0 – if the colormap is to be centered on 0 (diff plots).

Other arguments are passed to colorbounds().

norm()[source]

Normalize colormap, for each color occupy the same space on colorbar. Return the Norm object to be used by matplotlib.

ticks_label(*args, **kwargs)[source]

Return the labels of the ticks to be shown on colorbar. Arguments are passed to ticks_position(), in case of implicit ticks.

ticks_position(*args, **kwargs)[source]

Return the position of the ticks to be shown on colorbar. Arguments are passed to colorbounds(), in case of implicit ticks.

class epygram.colormapping.CenteredColormapHelper(colormap, explicit_colorcenters, normalize=True)[source]

Bases: epygram.colormapping.ColormapHelper

A specific ColormapHelper, where the values of ticks are explicitly defined, and colors must surround each tick.

Parameters
  • colormap – colormap: name of the colormap to be used

  • explicit_colorcenters – explicit values of the ticks and center values of each color.

  • normalize – if colors need to be normalized, i.e. that each color interval need to occupy the same space on the colorbar.

ticks_label(*_, **__)[source]

Return the labels of the ticks to be shown on colorbar.

ticks_position(*_, **__)[source]

Return the position of the ticks to be shown on colorbar.


epygram.colormapping.register_colormap_from_json(filename)[source]

Load colormap and metadata from file (json), register to matplotlib and return metadata.

epygram.colormapping.load_colormap(colormap)[source]

Load colormap from epygram colormaps if needed.