Skip to content

Commit 9044189

Browse files
committed
Update Colorizer/ColorizingArtist to work with MultiNorm
1 parent 0394f4e commit 9044189

File tree

6 files changed

+442
-70
lines changed

6 files changed

+442
-70
lines changed

lib/matplotlib/cbook.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,17 @@ def safe_masked_invalid(x, copy=False):
690690
try:
691691
xm = np.ma.masked_where(~(np.isfinite(x)), x, copy=False)
692692
except TypeError:
693-
return x
693+
if len(x.dtype.descr) == 1:
694+
return x
695+
else:
696+
# in case of a dtype with multiple fields:
697+
try:
698+
mask = np.empty(x.shape, dtype=np.dtype('bool, '*len(x.dtype.descr)))
699+
for dd, dm in zip(x.dtype.descr, mask.dtype.descr):
700+
mask[dm[0]] = ~(np.isfinite(x[dd[0]]))
701+
xm = np.ma.array(x, mask=mask, copy=False)
702+
except TypeError:
703+
return x
694704
return xm
695705

696706

lib/matplotlib/cm.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -239,32 +239,3 @@ def get_cmap(self, cmap):
239239
_multivar_colormaps = ColormapRegistry(multivar_cmaps)
240240

241241
_bivar_colormaps = ColormapRegistry(bivar_cmaps)
242-
243-
244-
def _ensure_cmap(cmap):
245-
"""
246-
Ensure that we have a `.Colormap` object.
247-
248-
For internal use to preserve type stability of errors.
249-
250-
Parameters
251-
----------
252-
cmap : None, str, Colormap
253-
254-
- if a `Colormap`, return it
255-
- if a string, look it up in mpl.colormaps
256-
- if None, look up the default color map in mpl.colormaps
257-
258-
Returns
259-
-------
260-
Colormap
261-
262-
"""
263-
if isinstance(cmap, colors.Colormap):
264-
return cmap
265-
cmap_name = mpl._val_or_rc(cmap, "image.cmap")
266-
# use check_in_list to ensure type stability of the exception raised by
267-
# the internal usage of this (ValueError vs KeyError)
268-
if cmap_name not in _colormaps:
269-
_api.check_in_list(sorted(_colormaps), cmap=cmap_name)
270-
return mpl.colormaps[cmap_name]

0 commit comments

Comments
 (0)