@@ -982,6 +982,11 @@ def _check_unsampled_image(self, renderer):
982982 """Return False. Do not use unsampled image."""
983983 return False
984984
985+ @cbook .deprecated ("3.3" )
986+ @property
987+ def is_grayscale (self ):
988+ return self ._is_grayscale
989+
985990 def make_image (self , renderer , magnification = 1.0 , unsampled = False ):
986991 # docstring inherited
987992 if self ._A is None :
@@ -992,11 +997,11 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
992997 if A .ndim == 2 :
993998 if A .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 if A .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 if A is not None :
11161121 self .set_data (x , y , A )
11171122
1123+ @cbook .deprecated ("3.3" )
1124+ @property
1125+ def is_grayscale (self ):
1126+ return self ._is_grayscale
1127+
11181128 def make_image (self , renderer , magnification = 1.0 , unsampled = False ):
11191129 # docstring inherited
11201130 if self ._A is None :
@@ -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 if self ._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 raise ValueError ("A must be 2D or 3D" )
11811191 if A .ndim == 3 and A .shape [2 ] == 1 :
11821192 A .shape = A .shape [:2 ]
1183- self .is_grayscale = False
1193+ self ._is_grayscale = False
11841194 if A .ndim == 3 :
11851195 if A .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 raise ValueError ("3D arrays must have RGB or RGBA as last dim" )
11911201
0 commit comments