@@ -6231,30 +6231,8 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
62316231 collection ._check_exclusionary_keywords (colorizer , vmin = vmin , vmax = vmax )
62326232 collection ._scale_norm (norm , vmin , vmax )
62336233
6234- # Transform from native to data coordinates?
6235- t = collection ._transform
6236- if (not isinstance (t , mtransforms .Transform ) and
6237- hasattr (t , '_as_mpl_transform' )):
6238- t = t ._as_mpl_transform (self .axes )
6239-
6240- if t and any (t .contains_branch_seperately (self .transData )):
6241- trans_to_data = t - self .transData
6242- pts = np .vstack ([x , y ]).T .astype (float )
6243- transformed_pts = trans_to_data .tran
7440
sform (pts )
6244- x = transformed_pts [..., 0 ]
6245- y = transformed_pts [..., 1 ]
6246-
6247- self .add_collection (collection , autolim = False )
6248-
6249- minx = np .min (x )
6250- maxx = np .max (x )
6251- miny = np .min (y )
6252- maxy = np .max (y )
6253- collection .sticky_edges .x [:] = [minx , maxx ]
6254- collection .sticky_edges .y [:] = [miny , maxy ]
6255- corners = (minx , miny ), (maxx , maxy )
6256- self .update_datalim (corners )
6257- self ._request_autoscale_view ()
6234+ coords = coords .reshape (- 1 , 2 ) # flatten the grid structure; keep x, y
6235+ self ._update_pcolor_lims (collection , coords )
62586236 return collection
62596237
62606238 @_preprocess_data ()
@@ -6464,7 +6442,13 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
64646442 collection ._scale_norm (norm , vmin , vmax )
64656443
64666444 coords = coords .reshape (- 1 , 2 ) # flatten the grid structure; keep x, y
6445+ self ._update_pcolor_lims (collection , coords )
6446+ return collection
64676447
6448+ def _update_pcolor_lims (self , collection , coords ):
6449+ """
6450+ Common code for updating lims in pcolor() and pcolormesh() methods.
6451+ """
64686452 # Transform from native to data coordinates?
64696453 t = collection ._transform
64706454 if (not isinstance (t , mtransforms .Transform ) and
@@ -6481,10 +6465,8 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
64816465 maxx , maxy = np .max (coords , axis = 0 )
64826466 collection .sticky_edges .x [:] = [minx , maxx ]
64836467 collection .sticky_edges .y [:] = [miny , maxy ]
6484- corners = (minx , miny ), (maxx , maxy )
6485- self .update_datalim (corners )
6468+ self .update_datalim (coords )
64866469 self ._request_autoscale_view ()
6487- return collection
64886470
64896471 @_preprocess_data ()
64906472 @_docstring .interpd
0 commit comments