plopp.graphics.ColorMapper#

class plopp.graphics.ColorMapper(canvas=None, cbar=True, cmap='viridis', mask_cmap='gray', norm='linear', autoscale='auto', vmin=None, vmax=None, nan_color=None, figsize=None)[source]#

A class that handles conversion between data values and RGBA colors. It controls the normalization (linear or log), as well as the min and max limits for the color range.

Parameters:
  • cax – The axes to use for the colorbar. If none are supplied, the ColorMapper will create its own axes.

  • cbar (bool, default: True) – Create a colorbar if True. If False, no colorbar is made even if cax is defined.

  • cmap (str, default: 'viridis') – The name of the colormap for the data (see https://matplotlib.org/stable/tutorials/colors/colormaps.html). In addition to the Matplotlib docs, if the name is just a single html color, a colormap with that single color will be used.

  • mask_cmap (str, default: 'gray') – The name of the colormap for masked data.

  • norm (Literal['linear', 'log'], default: 'linear') – The colorscale normalization.

  • autoscale (Literal['auto', 'grow'], default: 'auto') – The behavior of the color range limits. If auto, the limits automatically adjusts every time the data changes. If grow, the limits are allowed to grow with time but they do not shrink.

  • vmin (Union[Variable, int, float, None], default: None) – The minimum value for the colorscale range. If a number (without a unit) is supplied, it is assumed that the unit is the same as the data unit.

  • vmax (Union[Variable, int, float, None], default: None) – The maximum value for the colorscale range. If a number (without a unit) is supplied, it is assumed that the unit is the same as the data unit.

  • nan_color (Optional[str], default: None) – The color used for representing NAN values.

  • figsize (Optional[Tuple[float, float]], default: None) – The size of the figure next to which the colorbar will be displayed.

__init__(canvas=None, cbar=True, cmap='viridis', mask_cmap='gray', norm='linear', autoscale='auto', vmin=None, vmax=None, nan_color=None, figsize=None)[source]#

Methods

__init__([canvas, cbar, cmap, mask_cmap, ...])

autoscale()

Re-compute the global min and max range of values by iterating over all the artists.

rgba(data)

Return rgba values given a data array.

to_widget()

Convert the colorbar into a widget for use with other ipywidgets.

toggle_norm()

Toggle the norm flag, between linear and log.

update(*args, **kwargs)

Update the colorscale bounds taking into account new values, by either supplying a dictionary of new data or by keyword arguments.