Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit77bc51a

Browse files
committed
Update Colorizer/ColorizingArtist to work with MultiNorm
1 parent0394f4e commit77bc51a

File tree

6 files changed

+443
-71
lines changed

6 files changed

+443
-71
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
exceptTypeError:
693-
returnx
693+
iflen(x.dtype.descr)==1:
694+
returnx
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+
fordd,dminzip(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+
exceptTypeError:
703+
returnx
694704
returnxm
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-
ifisinstance(cmap,colors.Colormap):
264-
returncmap
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-
ifcmap_namenotin_colormaps:
269-
_api.check_in_list(sorted(_colormaps),cmap=cmap_name)
270-
returnmpl.colormaps[cmap_name]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp