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

Commit0ac66f3

Browse files
authored
Merge pull request#15394 from anntzer/is_grayscale
Deprecate {NonUniformImage,PcolorImage}.is_grayscale.
2 parentse672bf8 +5e5713c commit0ac66f3

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

‎doc/api/next_api_changes/deprecations.rst‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@ logging.
1616
``Colorbar.config_axis()``
1717
~~~~~~~~~~~~~~~~~~~~~~~~~~
1818
``Colorbar.config_axis()`` is considered internal. Its use is deprecated.
19+
20+
``NonUniformImage.is_grayscale`` and ``PcolorImage.is_grayscale``
21+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22+
These attributes are deprecated, for consistency with ``AxesImage.is_grayscale``,
23+
which was removed back in Matplotlib 2.0.0. (Note that previously, these
24+
attributes were only available *after rendering the image*).

‎lib/matplotlib/image.py‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,11 @@ def _check_unsampled_image(self, renderer):
982982
"""Return False. Do not use unsampled image."""
983983
returnFalse
984984

985+
@cbook.deprecated("3.3")
986+
@property
987+
defis_grayscale(self):
988+
returnself._is_grayscale
989+
985990
defmake_image(self,renderer,magnification=1.0,unsampled=False):
986991
# docstring inherited
987992
ifself._AisNone:
@@ -992,11 +997,11 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
992997
ifA.ndim==2:
993998
ifA.dtype!=np.uint8:
994999
A=self.to_rgba(A,bytes=True)
995-
self.is_grayscale=self.cmap.is_gray()
1000+
self._is_grayscale=self.cmap.is_gray()
9961001
else:
9971002
A=np.repeat(A[:, :,np.newaxis],4,2)
9981003
A[:, :,3]=255
999-
self.is_grayscale=True
1004+
self._is_grayscale=True
10001005
else:
10011006
ifA.dtype!=np.uint8:
10021007
A= (255*A).astype(np.uint8)
@@ -1005,7 +1010,7 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
10051010
B[:, :,0:3]=A
10061011
B[:, :,3]=255
10071012
A=B
1008-
self.is_grayscale=False
1013+
self._is_grayscale=False
10091014
x0,y0,v_width,v_height=self.axes.viewLim.bounds
10101015
l,b,r,t=self.axes.bbox.extents
10111016
width= (round(r)+0.5)- (round(l)-0.5)
@@ -1115,6 +1120,11 @@ def __init__(self, ax,
11151120
ifAisnotNone:
11161121
self.set_data(x,y,A)
11171122

1123+
@cbook.deprecated("3.3")
1124+
@property
1125+
defis_grayscale(self):
1126+
returnself._is_grayscale
1127+
11181128
defmake_image(self,renderer,magnification=1.0,unsampled=False):
11191129
# docstring inherited
11201130
ifself._AisNone:
@@ -1134,7 +1144,7 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
11341144
A=self.to_rgba(self._A,bytes=True)
11351145
self._rgbacache=A
11361146
ifself._A.ndim==2:
1137-
self.is_grayscale=self.cmap.is_gray()
1147+
self._is_grayscale=self.cmap.is_gray()
11381148
else:
11391149
A=self._rgbacache
11401150
vl=self.axes.viewLim
@@ -1180,12 +1190,12 @@ def set_data(self, x, y, A):
11801190
raiseValueError("A must be 2D or 3D")
11811191
ifA.ndim==3andA.shape[2]==1:
11821192
A.shape=A.shape[:2]
1183-
self.is_grayscale=False
1193+
self._is_grayscale=False
11841194
ifA.ndim==3:
11851195
ifA.shape[2]in [3,4]:
11861196
if ((A[:, :,0]==A[:, :,1]).all()and
11871197
(A[:, :,0]==A[:, :,2]).all()):
1188-
self.is_grayscale=True
1198+
self._is_grayscale=True
11891199
else:
11901200
raiseValueError("3D arrays must have RGB or RGBA as last dim")
11911201

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp