Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9a8df49

Browse filesBrowse files
anntzerImportanceOfBeingErnest
authored andcommitted
pcolorfast simplifications. (#13327)
1 parent 9aea67e commit 9a8df49
Copy full SHA for 9a8df49

File tree

Expand file treeCollapse file tree

1 file changed

+17
-42
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+17
-42
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+17-42Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6254,7 +6254,7 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
62546254
"'norm' must be an instance of 'mcolors.Normalize'")
62556255

62566256
C = args[-1]
6257-
nr, nc = C.shape
6257+
nr, nc = np.shape(C)
62586258
if len(args) == 1:
62596259
style = "image"
62606260
x = [0, nc]
@@ -6282,54 +6282,29 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
62826282
raise TypeError("need 1 argument or 3 arguments")
62836283

62846284
if style == "quadmesh":
6285-
6286-
# convert to one dimensional arrays
6287-
# This should also be moved to the QuadMesh class
6288-
62896285
# data point in each cell is value at lower left corner
6290-
C = ma.ravel(C)
6291-
X = x.ravel()
6292-
Y = y.ravel()
6293-
Nx = nc + 1
6294-
Ny = nr + 1
6295-
6296-
# The following needs to be cleaned up; the renderer
6297-
# requires separate contiguous arrays for X and Y,
6298-
# but the QuadMesh class requires the 2D array.
6299-
coords = np.empty(((Nx * Ny), 2), np.float64)
6300-
coords[:, 0] = X
6301-
coords[:, 1] = Y
6302-
6303-
# The QuadMesh class can also be changed to
6304-
# handle relevant superclass kwargs; the initializer
6305-
# should do much more than it does now.
6306-
collection = mcoll.QuadMesh(nc, nr, coords, 0, edgecolors="None")
6307-
collection.set_alpha(alpha)
6308-
collection.set_array(C)
6309-
collection.set_cmap(cmap)
6310-
collection.set_norm(norm)
6286+
coords = np.stack([x, y], axis=-1)
6287+
collection = mcoll.QuadMesh(
6288+
nc, nr, coords,
6289+
array=np.ma.ravel(C), alpha=alpha, cmap=cmap, norm=norm,
6290+
antialiased=False, edgecolors="none")
63116291
self.add_collection(collection, autolim=False)
6312-
xl, xr, yb, yt = X.min(), X.max(), Y.min(), Y.max()
6292+
xl, xr, yb, yt = x.min(), x.max(), y.min(), y.max()
63136293
ret = collection
63146294

63156295
else: # It's one of the two image styles.
6316-
xl, xr, yb, yt = x[0], x[-1], y[0], y[-1]
6317-
6296+
extent = xl, xr, yb, yt = x[0], x[-1], y[0], y[-1]
63186297
if style == "image":
6319-
im = mimage.AxesImage(self, cmap, norm,
6320-
interpolation='nearest',
6321-
origin='lower',
6322-
extent=(xl, xr, yb, yt),
6323-
**kwargs)
6324-
im.set_data(C)
6325-
im.set_alpha(alpha)
6298+
im = mimage.AxesImage(
6299+
self, cmap, norm,
6300+
data=C, alpha=alpha, extent=extent,
6301+
interpolation='nearest', origin='lower',
6302+
**kwargs)
63266303
elif style == "pcolorimage":
6327-
im = mimage.PcolorImage(self, x, y, C,
6328-
cmap=cmap,
6329-
norm=norm,
6330-
alpha=alpha,
6331-
**kwargs)
6332-
im.set_extent((xl, xr, yb, yt))
6304+
im = mimage.PcolorImage(
6305+
self, x, y, C,
6306+
cmap=cmap, norm=norm, alpha=alpha, extent=extent,
6307+
**kwargs)
63336308
self.add_image(im)
63346309
ret = im
63356310

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.