Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 54a945c

Browse files
committed
Changes to colorizer to prepare for multivariate plotting
1 parent 5e0266a commit 54a945c

File tree

5 files changed

+288
-74
lines changed

5 files changed

+288
-74
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
@@ -278,32 +278,3 @@ def get_cmap(name=None, lut=None):
278278
return _colormaps[name]
279279
else:
280280
return _colormaps[name].resampled(lut)
281-
282-
283-
def _ensure_cmap(cmap):
284-
"""
285-
Ensure that we have a `.Colormap` object.
286-
287-
For internal use to preserve type stability of errors.
288-
289-
Parameters
290-
----------
291-
cmap : None, str, Colormap
292-
293-
- if a `Colormap`, return it
294-
- if a string, look it up in mpl.colormaps
295-
- if None, look up the default color map in mpl.colormaps
296-
297-
Returns
298-
-------
299-
Colormap
300-
301-
"""
302-
if isinstance(cmap, colors.Colormap):
303-
return cmap
304-
cmap_name = mpl._val_or_rc(cmap, "image.cmap")
305-
# use check_in_list to ensure type stability of the exception raised by
306-
# the internal usage of this (ValueError vs KeyError)
307-
if cmap_name not in _colormaps:
308-
_api.check_in_list(sorted(_colormaps), cmap=cmap_name)
309-
return mpl.colormaps[cmap_name]

0 commit comments

Comments
 (0)