Skip to content

Commit 736bed8

Browse files
committed
Make pcolor and pcolormesh code similar
1 parent 14c221d commit 736bed8

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6231,6 +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+
coords = coords.reshape(-1, 2) # flatten the grid structure; keep x, y
6235+
62346236
# Transform from native to data coordinates?
62356237
t = collection._transform
62366238
if (not isinstance(t, mtransforms.Transform) and
@@ -6239,20 +6241,15 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
62396241

62406242
if t and any(t.contains_branch_seperately(self.transData)):
62416243
trans_to_data = t - self.transData
6242-
pts = np.vstack([x, y]).T.astype(float)
6243-
transformed_pts = trans_to_data.transform(pts)
6244-
x = transformed_pts[..., 0]
6245-
y = transformed_pts[..., 1]
6244+
coords = trans_to_data.transform(coords)
62466245

62476246
self.add_collection(collection, autolim=False)
62486247

6249-
minx = np.min(x)
6250-
maxx = np.max(x)
6251-
miny = np.min(y)
6252-
maxy = np.max(y)
6248+
minx, miny = np.min(coords, axis=0)
6249+
maxx, maxy = np.max(coords, axis=0)
62536250
collection.sticky_edges.x[:] = [minx, maxx]
62546251
collection.sticky_edges.y[:] = [miny, maxy]
6255-
self.update_datalim(coords.reshape(-1, 2))
6252+
self.update_datalim(coords)
62566253
self._request_autoscale_view()
62576254
return collection
62586255

0 commit comments

Comments
 (0)