plopp.graphics.ColorMapper#
- class plopp.graphics.ColorMapper(canvas=None, cbar=True, cmap='viridis', mask_cmap='gray', norm='linear', 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 ifTrue
. IfFalse
, no colorbar is made even ifcax
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.vmin (
Union
[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.vmax (
Union
[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.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', vmin=None, vmax=None, nan_color=None, figsize=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.
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
unit
Get or set the unit of the colorbar.
vmax
Get or set the maximum value of the colorbar.
vmin
Get or set the minimum value of the colorbar.
ylabel
Get or set the label of the colorbar axis.