@@ -982,6 +982,11 @@ def _check_unsampled_image(self, renderer):
982
982
"""Return False. Do not use unsampled image."""
983
983
return False
984
984
985
+ @cbook .deprecated ("3.3" )
986
+ @property
987
+ def is_grayscale (self ):
988
+ return self ._is_grayscale
989
+
985
990
def make_image (self , renderer , magnification = 1.0 , unsampled = False ):
986
991
# docstring inherited
987
992
if self ._A is None :
@@ -992,11 +997,11 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
992
997
if A .ndim == 2 :
993
998
if A .dtype != np .uint8 :
994
999
A = self .to_rgba (A , bytes = True )
995
- self .is_grayscale = self .cmap .is_gray ()
1000
+ self ._is_grayscale = self .cmap .is_gray ()
996
1001
else :
997
1002
A = np .repeat (A [:, :, np .newaxis ], 4 , 2 )
998
1003
A [:, :, 3 ] = 255
999
- self .is_grayscale = True
1004
+ self ._is_grayscale = True
1000
1005
else :
1001
1006
if A .dtype != np .uint8 :
1002
1007
A = (255 * A ).astype (np .uint8 )
@@ -1005,7 +1010,7 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
1005
1010
B [:, :, 0 :3 ] = A
1006
1011
B [:, :, 3 ] = 255
1007
1012
A = B
1008
- self .is_grayscale = False
1013
+ self ._is_grayscale = False
1009
1014
x0 , y0 , v_width , v_height = self .axes .viewLim .bounds
1010
1015
l , b , r , t = self .axes .bbox .extents
1011
1016
width = (round (r ) + 0.5 ) - (round (l ) - 0.5 )
@@ -1115,6 +1120,11 @@ def __init__(self, ax,
1115
1120
if A is not None :
1116
1121
self .set_data (x , y , A )
1117
1122
1123
+ @cbook .deprecated ("3.3" )
1124
+ @property
1125
+ def is_grayscale (self ):
1126
+ return self ._is_grayscale
1127
+
1118
1128
def make_image (self , renderer , magnification = 1.0 , unsampled = False ):
1119
1129
# docstring inherited
1120
1130
if self ._A is None :
@@ -1134,7 +1144,7 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
1134
1144
A = self .to_rgba (self ._A , bytes = True )
1135
1145
self ._rgbacache = A
1136
1146
if self ._A .ndim == 2 :
1137
- self .is_grayscale = self .cmap .is_gray ()
1147
+ self ._is_grayscale = self .cmap .is_gray ()
1138
1148
else :
1139
1149
A = self ._rgbacache
1140
1150
vl = self .axes .viewLim
@@ -1180,12 +1190,12 @@ def set_data(self, x, y, A):
1180
1190
raise ValueError ("A must be 2D or 3D" )
1181
1191
if A .ndim == 3 and A .shape [2 ] == 1 :
1182
1192
A .shape = A .shape [:2 ]
1183
- self .is_grayscale = False
1193
+ self ._is_grayscale = False
1184
1194
if A .ndim == 3 :
1185
1195
if A .shape [2 ] in [3 , 4 ]:
1186
1196
if ((A [:, :, 0 ] == A [:, :, 1 ]).all () and
1187
1197
(A [:, :, 0 ] == A [:, :, 2 ]).all ()):
1188
- self .is_grayscale = True
1198
+ self ._is_grayscale = True
1189
1199
else :
1190
1200
raise ValueError ("3D arrays must have RGB or RGBA as last dim" )
1191
1201
0 commit comments