@@ -5151,8 +5151,11 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
5151
5151
raise ValueError (msg )
5152
5152
5153
5153
temp = np .asarray (X )
5154
- is_bivari = (temp .ndim == 3 or temp .shape [0 ] == 2 )
5154
+ is_bivari = (isinstance (norm , mcolors .BivariateNorm ) or
5155
+ isinstance (cmap , mcolors .BivariateColormap ))
5155
5156
if is_bivari :
5157
+ if temp .ndim != 3 and temp .shape [0 ] != 2 :
5158
+ raise TypeError ("Expected shape like (2, n, m)" )
5156
5159
if cmap is None :
5157
5160
cmap = mcolors .BivariateColormap ()
5158
5161
if norm is None :
@@ -5205,7 +5208,8 @@ def _pcolorargs(funcname, *args, **kw):
5205
5208
5206
5209
if len (args ) == 1 :
5207
5210
C = np .asanyarray (args [0 ])
5208
- is_bivari = (C .ndim == 3 or C .shape [0 ] == 2 )
5211
+ is_bivari = (isinstance (norm , mcolors .BivariateNorm ) or
5212
+ isinstance (cmap , mcolors .BivariateColormap ))
5209
5213
if is_bivari :
5210
5214
numRows , numCols = C .shape [1 :]
5211
5215
else :
@@ -5220,12 +5224,9 @@ def _pcolorargs(funcname, *args, **kw):
5220
5224
5221
5225
if len (args ) == 3 :
5222
5226
X , Y , C = [np .asanyarray (a ) for a in args ]
5223
- is_bivari = (C .ndim == 3 or C .shape [0 ] == 2 )
5227
+ is_bivari = (isinstance (norm , mcolors .BivariateNorm ) or
5228
+ isinstance (cmap , mcolors .BivariateColormap ))
5224
5229
if is_bivari :
5225
- if cmap is None :
5226
- cmap = mcolors .BivariateColormap ()
5227
- if norm is None :
5228
- norm = mcolors .BivariateNorm ()
5229
5230
numRows , numCols = C .shape [1 :]
5230
5231
else :
5231
5232
numRows , numCols = C .shape
@@ -5414,8 +5415,11 @@ def pcolor(self, *args, **kwargs):
5414
5415
X , Y , C = self ._pcolorargs ('pcolor' , * args , ** kw )
5415
5416
Ny , Nx = X .shape
5416
5417
5417
- is_bivari = (C .ndim == 3 or C .shape [0 ] == 2 )
5418
+ is_bivari = (isinstance (norm , mcolors .BivariateNorm ) or
5419
+ isinstance (cmap , mcolors .BivariateColormap ))
5418
5420
if is_bivari :
5421
+ if C .ndim != 3 and C .shape [0 ] != 2 :
5422
+ raise TypeError ("Expected shape like (2, n, m)" )
5419
5423
if cmap is None :
5420
5424
cmap = mcolors .BivariateColormap ()
5421
5425
if norm is None :
@@ -5638,8 +5642,11 @@ def pcolormesh(self, *args, **kwargs):
5638
5642
X , Y , C = self ._pcolorargs ('pcolormesh' , * args , ** kw )
5639
5643
Ny , Nx = X .shape
5640
5644
5641
- is_bivari = (C .ndim == 3 or C .shape [0 ] == 2 )
5645
+ is_bivari = (isinstance (norm , mcolors .BivariateNorm ) or
5646
+ isinstance (cmap , mcolors .BivariateColormap ))
5642
5647
if is_bivari :
5648
+ if C .ndim != 3 and C .shape [0 ] != 2 :
5649
+ raise TypeError ("Expected shape like (2, n, m)" )
5643
5650
if cmap is None :
5644
5651
cmap = mcolors .BivariateColormap ()
5645
5652
if norm is None :
@@ -5798,8 +5805,11 @@ def pcolorfast(self, *args, **kwargs):
5798
5805
5799
5806
C = np .asarray (args [- 1 ])
5800
5807
5801
- is_bivari = (C .ndim == 3 or C .shape [0 ] == 2 )
5808
+ is_bivari = (isinstance (norm , mcolors .BivariateNorm ) or
5809
+ isinstance (cmap , mcolors .BivariateColormap ))
5802
5810
if is_bivari :
5811
+ if C .ndim != 3 and C .shape [0 ] != 2 :
5812
+ raise TypeError ("Expected shape like (2, n, m)" )
5803
5813
if cmap is None :
5804
5814
cmap = mcolors .BivariateColormap ()
5805
5815
if norm is None :
0 commit comments