matplotlib.colors.BoundaryNorm#
- classmatplotlib.colors.BoundaryNorm(boundaries,ncolors,clip=False,*,extend='neither')[source]#
Bases:
Normalize
Generate a colormap index based on discrete intervals.
Unlike
Normalize
orLogNorm
,BoundaryNorm
maps values to integersinstead of to the interval 0-1.- Parameters:
- boundariesarray-like
Monotonically increasing sequence of at least 2 bin edges: datafalling in the n-th bin will be mapped to the n-th color.
- ncolorsint
Number of colors in the colormap to be used.
- clipbool, optional
If clip is
True
, out of range values are mapped to 0 if theyare belowboundaries[0]
or mapped toncolors-1
if theyare aboveboundaries[-1]
.If clip is
False
, out of range values are mapped to -1 ifthey are belowboundaries[0]
or mapped toncolors if they areaboveboundaries[-1]
. These are then converted to valid indicesbyColormap.__call__
.- extend{'neither', 'both', 'min', 'max'}, default: 'neither'
Extend the number of bins to include one or both of theregions beyond the boundaries. For example, if
extend
is 'min', then the color to which the region between the firstpair of boundaries is mapped will be distinct from the firstcolor in the colormap, and by default aColorbar
will be drawn withthe triangle extension on the left or lower end.
Notes
If there are fewer bins (including extensions) than colors, then thecolor index is chosen by linearly interpolating the
[0,nbins-1]
range onto the[0,ncolors-1]
range, effectively skipping somecolors in the middle of the colormap.- __call__(value,clip=None)[source]#
This method behaves similarly to
Normalize.__call__
, except that itreturns integers or arrays of int16.