plopp.graphics.ColorMapper#
- class plopp.graphics.ColorMapper(canvas=None, cbar=True, cmap='viridis', mask_cmap='gray', mask_color=None, cmin=None, cmax=None, logc=None, clabel=None, nan_color=None, figsize=None, norm=None, vmin=None, vmax=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 ifTrue. IfFalse, no colorbar is made even ifcaxis defined.cmap (
str|Colormap, 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|Colormap, default:'gray') – The name of the colormap for masked data.cmin (
Variable|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.cmax (
Variable|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.logc (
bool|None, default:None) – IfTrue, use a logarithmic colorscale.nan_color (
str|None, default:None) – The color used for representing NAN values.figsize (
tuple[float,float] |None, default:None) – The size of the figure next to which the colorbar will be displayed.norm (
Literal['linear','log',None], default:None) – The colorscale normalization. This is an old parameter name. Prefer usinglogcinstead.vmin (
Variable|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. This is an old parameter name. Prefer usingcmininstead.vmax (
Variable|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. This is an old parameter name. Prefer usingcmaxinstead.
- __init__(canvas=None, cbar=True, cmap='viridis', mask_cmap='gray', mask_color=None, cmin=None, cmax=None, logc=None, clabel=None, nan_color=None, figsize=None, norm=None, vmin=None, vmax=None)[source]#
Methods
__init__([canvas, cbar, cmap, mask_cmap, ...])add_artist(key, artist)apply_limits()autoscale()Re-compute the global min and max range of values by iterating over all the artists and adjust the limits.
has_user_clabel()Return
Trueif the user has set a colorbar label.notify_artists()Notify the artists that the state of the colormapper has changed.
remove_artist(key)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.
Attributes
clabelGet or set the label of the colorbar axis.
cmaxGet or set the maximum value of the colorbar.
cminGet or set the minimum value of the colorbar.
normGet or set the colorscale normalization.
unitGet or set the unit of the colorbar.
vmaxGet or set the maximum value of the colorbar.
vminGet or set the minimum value of the colorbar.
ylabelGet or set the label of the colorbar axis.