@@ -1429,9 +1429,9 @@ def __init__(self, boundaries, ncolors, clip=False, *, extend='neither'):
14291429 Parameters
14301430 ----------
14311431 boundaries : array-like
1432- Monotonically increasing sequence of boundaries
1432+ Monotonically increasing sequence of boundaries.
14331433 ncolors : int
1434- Number of colors in the colormap to be used
1434+ Number of colors in the colormap to be used.
14351435 clip : bool, optional
14361436 If clip is ``True``, out of range values are mapped to 0 if they
14371437 are below ``boundaries[0]`` or mapped to ``ncolors - 1`` if they
@@ -1492,6 +1492,7 @@ def __call__(self, value, clip=None):
14921492
14931493 xx , is_scalar = self .process_value (value )
14941494 mask = np .ma .getmaskarray (xx )
1495+ # Fill masked values a value above the upper boundary
14951496 xx = np .atleast_1d (xx .filled (self .vmax + 1 ))
14961497 if clip :
14971498 np .clip (xx , self .vmin , self .vmax , out = xx )
@@ -1500,7 +1501,10 @@ def __call__(self, value, clip=None):
15001501 max_col = self .Ncmap
15011502 iret = np .digitize (xx , self .boundaries ) - 1 + self ._offset
15021503 if self .Ncmap > self ._n_regions :
1503- scalefac = (self .Ncmap - 1 ) / (self ._n_regions - 1 )
1504+ if self ._n_regions == 1 :
1505+ scalefac = 1
1506+ else :
1507+ scalefac = (self .Ncmap - 1 ) / (self ._n_regions - 1 )
15041508 iret = (iret * scalefac ).astype (np .int16 )
15051509 iret [xx < self .vmin ] = - 1
15061510 iret [xx >= self .vmax ] = max_col
0 commit comments