PlasmaCalcs.plotting.plot_tools.colors.Colormap

class PlasmaCalcs.plotting.plot_tools.colors.Colormap(*args_super, under=NO_VALUE, over=NO_VALUE, bad=NO_VALUE, **kw_super)

Bases: BaseColormap, ListedColormap

matplotlib.colors.ListedColormap with some extra methods.
under: NO_VALUE, None, str, or other specifier for a color.
the color for low out-of-range values.
if provided (not NO_VALUE), sets self.under = under.
over: NO_VALUE, None, str, or other specifier for a color.
the color for high out-of-range values.
if provided (not NO_VALUE), sets self.over = over.
bad: NO_VALUE, None, str, or other specifier for a color.
the color for masked values.
if provided (not NO_VALUE), sets self.bad = bad.
see help(mpl.colors.ListedColormap) for more details on __init__.
__init__(*args_super, under=NO_VALUE, over=NO_VALUE, bad=NO_VALUE, **kw_super)
Parameters
———-
namestr
The name of the colormap.
Nint
The number of RGB quantization levels.

Methods

__init__(*args_super[, under, over, bad])

at(fractions)

copy()

from_cmap(cmap, **kw)

get_bad()

get_cmap([based_on, N, colors, name, ...])

get_extremes()

get_over()

get_under()

is_gray()

resampled(N, **kw__super)

reversed([name])

set_bad([color, alpha])

set_extremes(*[, under, over, bad])

set_over([color, alpha])

set_under([color, alpha])

shrink([min, max, N])

with_bad(bad)

with_extremes(*[, under, over, bad])

with_over(over)

with_under(under)

Attributes

bad

colorbar_extend

colorbar_extend_settings

extremes

over

under

at(fractions)
return copy of self but only keep colors at self(fractions).
E.g. self.at([0.1, 0.5, 0.9]) gives cmap with N=3,
and colors at 10%, 50%, and 90% of the way along self.
property bad
the color for masked values. Use self.bad=None to restore default.
property colorbar_extend
defaults instructions for whether to extend colorbars using this colormap.
One of the following values:
‘neither’ –> do not extend colorbar.
‘both’ –> extend colorbar in both directions.
‘min’ –> extend colorbar in the direction of the minimum value.
‘max’ –> extend colorbar in the direction of the maximum value.
When setting self.colorbar_extend=value, value can be:
str –> use value (must be ‘neither’, ‘both’, ‘min’, or ‘max’).
True –> use ‘both’
False –> use ‘neither’
property colorbar_extend_settings
the current dict(under=bool, over=bool) corresponding to colorbar_extend.
copy()
Return a copy of the colormap.
property extremes
(under, over, bad), as a ColormapExtremes namedtuple.
setting self.extremes = value is possible, but to avoid ambiguity:
value must have keys “under”, “over”, and/or “bad”,
or attributes “under”, “over”, and/or “bad”.
e.g. self.extremes = dict(under=’blue’)
(equivalent to self.under=’blue’)
Use None to reset to default, e.g. self.extremes = None,
(equivalent to self.under=None, self.over=None, self.bad=None)
or for any keys, e.g. self.extremes = dict(under=’blue’, over=None)
(equivalent to self.under=’blue’, self.over=None, but not adjusting self.bad)
classmethod from_cmap(cmap, **kw)
return Colormap from cmap.
cmap: Colormap or matplotlib.colors.ListedColormap
[TODO] or matplotlib.colors.LinearSegmentedColormap
additional kwargs go to cls.__new__ and cls.__init__.
get_bad()
Get the color for masked values.
classmethod get_cmap(based_on=None, N=None, *, colors=None, name=None, reversed=False, under=NO_VALUE, over=NO_VALUE, bad=NO_VALUE, **kw_init)
Get a Colormap instance, possibly based on a default colormap from matplotlib.
based_on: matplotlib.colors.Colormap, str, or None
the colormap to base the result on.
None –> use the default colormap (from matplotlib rc; image.cmap)
(or, if colors are provided, use colors to make a new colormap instead).
str –> use the colormap with this name from matplotlib.
(or, if colors are provided, set this to the name of the new colormap).
Colormap –> base the result on this colormap.
(mutually exclusive with providing a value for colors)
N: None or int
number of colors to use.
None –> use the number of colors in based_on.
int –> resample to this many colors.
colors: None or array-like of colors
None –> ignore this parameter
array-like –> provide these to make a new Colormap.
(mutually exclusive with providing a Colormap for based_on)
name: None or str
the name for the new Colormap.
if None, infer name from the old colormap or the provided value of based_on.
reversed: bool
whether to return result.reversed(), instead.
under: NO_VALUE, None, str, or other specifier for a color.
the color for low out-of-range values.
if provided (not NO_VALUE), sets result.under = under.
over: NO_VALUE, None, str, or other specifier for a color.
the color for high out-of-range values.
if provided (not NO_VALUE), sets result.over = over.
bad: NO_VALUE, None, str, or other specifier for a color.
the color for masked values.
if provided (not NO_VALUE), sets result.bad = bad.
additional kwargs are passed to cls(…) when creating the result.
get_extremes()
return (under, over, bad) colors, as a ColormapExtremes namedtuple.
get_over()
Get the color for high out-of-range values.
get_under()
Get the color for low out-of-range values.
is_gray()
Return whether the colormap is grayscale.
property over
the color for high out-of-range values.
when setting self.over = value, value can be:
str –> use this color.
None or bool –> use the default color (top of the colormap).
if not None, also sets self.colorbar_extend_settings[‘over’],
to True if (str or True), else False.
resampled(N, **kw__super)
return a copy of self, resampled to size N.
reversed(name=None, **kw__super)
return a copy of self, with reversed colors.
if name is None, use name = self.name + “_r”.
set_bad(color=None, alpha=None, **kw_super)
set the color for masked values. See help(type(self).bad) for details.
set_extremes(*, under=NO_VALUE, over=NO_VALUE, bad=NO_VALUE)
set under, over, bad colors, based on keywords.
see help(type(self).extremes) for details.
set_over(color=None, alpha=None, **kw_super)
set the color for high out-of-range values. See help(type(self).over) for details.
set_under(color=None, alpha=None, **kw_super)
set the color for low out-of-range values. See help(type(self).under) for details.
shrink(min=0, max=1, N=None)
return copy of self but only keep colors between min and max.
E.g. self.shrink(0.2, 0.7) only keeps colors between 20% and 70% of the way along self.
N: None or int
number of colors to use for the result.
None –> keep similar spacing of colors as in self
property under
the color for low out-of-range values.
when setting self.under = value, value can be:
str –> use this color.
None –> use the default color (bottom of the colormap).
if not None, also sets self.colorbar_extend_settings[‘under’],
to True if (str or True), else False.
with_bad(bad)
return a copy of self, with new color for bad.
with_extremes(*, under=NO_VALUE, over=NO_VALUE, bad=NO_VALUE)
return a copy of self, with new colors for under, over, and/or bad.
see help(type(self).extremes) for details.
with_over(over)
return a copy of self, with new color for over.
with_under(under)
return a copy of self, with new color for under.