FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Update Colorizer/ColorizingArtist to work with MultiNorm by trygvrad · Pull Request #30511 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (6) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
16 changes: 15 additions & 1 deletion lib/matplotlib/cbook.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,21 @@ def safe_masked_invalid(x, copy=False):
try:
xm = np.ma.masked_where(~(np.isfinite(x)), x, copy=False)
except TypeError:
return x
if len(x.dtype.descr) == 1:
# Arrays with dtype 'object' get returned here.
# For example the 'c' kwarg of scatter, which supports multiple types.
# `plt.scatter([3, 4], [2, 5], c=[(1, 0, 0), 'y'])`
return x
else:
# In case of a dtype with multiple fields
# for example image data using a MultiNorm
try:
mask = np.empty(x.shape, dtype=np.dtype('bool, '*len(x.dtype.descr)))
for dd, dm in zip(x.dtype.descr, mask.dtype.descr):
mask[dm[0]] = ~np.isfinite(x[dd[0]])
xm = np.ma.array(x, mask=mask, copy=False)
except TypeError:
return x
return xm


Expand Down
29 changes: 0 additions & 29 deletions lib/matplotlib/cm.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -239,32 +239,3 @@ def get_cmap(self, cmap):
_multivar_colormaps = ColormapRegistry(multivar_cmaps)

_bivar_colormaps = ColormapRegistry(bivar_cmaps)


def _ensure_cmap(cmap):
"""
Ensure that we have a `.Colormap` object.

For internal use to preserve type stability of errors.

Parameters
----------
cmap : None, str, Colormap

- if a `Colormap`, return it
- if a string, look it up in mpl.colormaps
- if None, look up the default color map in mpl.colormaps

Returns
-------
Colormap

"""
if isinstance(cmap, colors.Colormap):
return cmap
cmap_name = mpl._val_or_rc(cmap, "image.cmap")
# use check_in_list to ensure type stability of the exception raised by
# the internal usage of this (ValueError vs KeyError)
if cmap_name not in _colormaps:
_api.check_in_list(sorted(_colormaps), cmap=cmap_name)
return mpl.colormaps[cmap_name]
Loading
Loading

Back | FazBrowse Home | New Git URL