You are viewing the latest unreleased documentation 3.9.0.dev5. You can switch to a stable version.

iris.palette#

Color map pallettes management.

Load, configure and register color map palettes and initialise color map meta-data mappings.

class iris.palette.SymmetricNormalize(pivot, *args, **kwargs)[source]#

Bases: Normalize

Provides a symmetric normalization class around a given pivot point.

Parameters:
  • vmin (float or None) – If vmin and/or vmax is not given, they are initialized from the minimum and maximum value, respectively, of the first input processed; i.e., __call__(A) calls autoscale_None(A).

  • vmax (float or None) – If vmin and/or vmax is not given, they are initialized from the minimum and maximum value, respectively, of the first input processed; i.e., __call__(A) calls autoscale_None(A).

  • clip (bool, default: False) –

    Determines the behavior for mapping values outside the range [vmin, vmax].

    If clipping is off, values outside the range [vmin, vmax] are also transformed linearly, resulting in values outside [0, 1]. For a standard use with colormaps, this behavior is desired because colormaps mark these outside values with specific colors for over or under.

    If True values falling outside the range [vmin, vmax], are mapped to 0 or 1, whichever is closer. This makes these values indistinguishable from regular boundary values and can lead to misinterpretation of the data.

Notes

Returns 0 if vmin == vmax.

__call__(value, clip=None)#

Normalize value data in the [vmin, vmax] interval into the [0.0, 1.0] interval and return it.

Parameters:
  • value – Data to normalize.

  • clip (bool, optional) –

    See the description of the parameter clip in .Normalize.

    If None, defaults to self.clip (which defaults to False).

Notes

If not already initialized, self.vmin and self.vmax are initialized using self.autoscale_None(value).

autoscale(A)#

Set vmin, vmax to min, max of A.

autoscale_None(A)#

If vmin or vmax are not set, use the min/max of A to set them.

property clip#
inverse(value)#
static process_value(value)#

Homogenize the input value for easy and efficient normalization.

value can be a scalar or sequence.

Returns:

  • result (masked array) – Masked array with the same shape as value.

  • is_scalar (bool) – Whether value is a scalar.

Notes

Float dtypes are preserved; integer types with two bytes or smaller are converted to np.float32, and larger types are converted to np.float64. Preserving float32 when possible, and using in-place operations, greatly improves speed for large arrays.

scaled()#

Return whether vmin and vmax are set.

property vmax#
property vmin#
iris.palette.auto_palette(func)[source]#

Auto palette decorator wrapper function to control the default behaviour.

Decorator wrapper function to control the default behaviour of the matplotlib cmap and norm keyword arguments.

Parameters:

func (callable) – Callable function to be wrapped by the decorator.

Return type:

Closure wrapper function.

iris.palette.cmap_norm(cube)[source]#

Determine the default.

Determine the default matplotlib.colors.LinearSegmentedColormap and iris.palette.SymmetricNormalize instances associated with the cube.

Parameters:

cube (iris.cube.Cube) – Source cube to generate default palette from.

Returns:

Tuple of matplotlib.colors.LinearSegmentedColormap and iris.palette.SymmetricNormalize

Return type:

tuple

Notes

This function maintains laziness when called; it does not realise data. See more at Real and Lazy Data.

iris.palette.is_brewer(cmap)[source]#

Determine whether the color map is a Cynthia Brewer color map.

Parameters:

cmap – The color map instance.

Return type:

bool