@@ -5151,8 +5151,11 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
51515151 raise ValueError (msg )
51525152
51535153 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 ))
51555156 if is_bivari :
5157+ if temp .ndim != 3 and temp .shape [0 ] != 2 :
5158+ raise TypeError ("Expected shape like (2, n, m)" )
51565159 if cmap is None :
51575160 cmap = mcolors .BivariateColormap ()
51585161 if norm is None :
@@ -5205,7 +5208,8 @@ def _pcolorargs(funcname, *args, **kw):
52055208
52065209 if len (args ) == 1 :
52075210 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 ))
52095213 if is_bivari :
52105214 numRows , numCols = C .shape [1 :]
52115215 else :
@@ -5220,12 +5224,9 @@ def _pcolorargs(funcname, *args, **kw):
52205224
52215225 if len (args ) == 3 :
52225226 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 ))
52245229 if is_bivari :
5225- if cmap is None :
5226- cmap = mcolors .BivariateColormap ()
5227- if norm is None :
5228- norm = mcolors .BivariateNorm ()
52295230 numRows , numCols = C .shape [1 :]
52305231 else :
52315232 numRows , numCols = C .shape
@@ -5414,8 +5415,11 @@ def pcolor(self, *args, **kwargs):
54145415 X , Y , C = self ._pcolorargs ('pcolor' , * args , ** kw )
54155416 Ny , Nx = X .shape
54165417
5417- is_bivari = (C .ndim == 3 or C .shape [0 ] == 2 )
5418+ is_bivari = (isinstance (norm , mcolors .BivariateNorm ) or
5419+ isinstance (cmap , mcolors .BivariateColormap ))
54185420 if is_bivari :
5421+ if C .ndim != 3 and C .shape [0 ] != 2 :
5422+ raise TypeError ("Expected shape like (2, n, m)" )
54195423 if cmap is None :
54205424 cmap = mcolors .BivariateColormap ()
54215425 if norm is None :
@@ -5638,8 +5642,11 @@ def pcolormesh(self, *args, **kwargs):
56385642 X , Y , C = self ._pcolorargs ('pcolormesh' , * args , ** kw )
56395643 Ny , Nx = X .shape
56405644
5641- is_bivari = (C .ndim == 3 or C .shape [0 ] == 2 )
5645+ is_bivari = (isinstance (norm , mcolors .BivariateNorm ) or
5646+ isinstance (cmap , mcolors .BivariateColormap ))
56425647 if is_bivari :
5648+ if C .ndim != 3 and C .shape [0 ] != 2 :
5649+ raise TypeError ("Expected shape like (2, n, m)" )
56435650 if cmap is None :
56445651 cmap = mcolors .BivariateColormap ()
56455652 if norm is None :
@@ -5798,8 +5805,11 @@ def pcolorfast(self, *args, **kwargs):
57985805
57995806 C = np .asarray (args [- 1 ])
58005807
5801- is_bivari = (C .ndim == 3 or C .shape [0 ] == 2 )
5808+ is_bivari = (isinstance (norm , mcolors .BivariateNorm ) or
5809+ isinstance (cmap , mcolors .BivariateColormap ))
58025810 if is_bivari :
5811+ if C .ndim != 3 and C .shape [0 ] != 2 :
5812+ raise TypeError ("Expected shape like (2, n, m)" )
58035813 if cmap is None :
58045814 cmap = mcolors .BivariateColormap ()
58055815 if norm is None :
0 commit comments