8000 Merge pull request #8801 from QuLogic/pcolormesh-redundancies · matplotlib/matplotlib@5a06397 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5a06397

Browse files
authored
Merge pull request #8801 from QuLogic/pcolormesh-redundancies
Remove redundant variables in pcolormesh.
2 parents 03dd8e4 + c3a0786 commit 5a06397

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5524,19 +5524,14 @@ def pcolormesh(self, *args, **kwargs):
55245524
X, Y, C = self._pcolorargs('pcolormesh', *args, allmatch=allmatch)
55255525
Ny, Nx = X.shape
55265526

5527-
# convert to one dimensional arrays
5528-
C = C.ravel()
5529-
X = X.ravel()
5530-
Y = Y.ravel()
5531-
55325527
# unit conversion allows e.g. datetime objects as axis values
55335528
self._process_unit_info(xdata=X, ydata=Y, kwargs=kwargs)
55345529
X = self.convert_xunits(X)
55355530
Y = self.convert_yunits(Y)
55365531

5537-
coords = np.zeros(((Nx * Ny), 2), dtype=float)
5538-
coords[:, 0] = X
5539-
coords[:, 1] = Y
5532+
# convert to one dimensional arrays
5533+
C = C.ravel()
5534+
coords = np.column_stack((X.flat, Y.flat)).astype(float, copy=False)
55405535

55415536
collection = mcoll.QuadMesh(Nx - 1, Ny - 1, coords,
55425537
antialiased=antialiased, shading=shading,
@@ -5561,17 +5556,12 @@ def pcolormesh(self, *args, **kwargs):
55615556

55625557
if t and any(t.contains_branch_seperately(self.transData)):
55635558
trans_to_data = t - self.transData
5564-
pts = np.vstack([X, Y]).T.astype(float)
5565-
transformed_pts = trans_to_data.transform(pts)
5566-
X = transformed_pts[..., 0]
5567-
Y = transformed_pts[..., 1]
5559+
coords = trans_to_data.transform(coords)
55685560

55695561
self.add_collection(collection, autolim=False)
55705562

5571-
minx = np.min(X)
5572-
maxx = np.max(X)
5573-
miny = np.min(Y)
5574-
maxy = np.max(Y)
5563+
minx, miny = np.min(coords, axis=0)
5564+
maxx, maxy = np.max(coords, axis=0)
55755565
collection.sticky_edges.x[:] = [minx, maxx]
55765566
collection.sticky_edges.y[:] = [miny, maxy]
55775567
corners = (minx, miny), (maxx, maxy)

0 commit comments

Comments
 (0)
0