8000 pcolor optimization - my tests show it's 2-3 times faster. · matplotlib/matplotlib@dfeb83e · GitHub
[go: up one dir, main page]

Skip to content

Commit dfeb83e

Browse files
author
Jeff Whitaker
committed
pcolor optimization - my tests show it's 2-3 times faster.
Fixed bug is previous patch. svn path=/trunk/matplotlib/; revision=1339
1 parent 281b7b7 commit dfeb83e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lib/matplotlib/axes.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,11 +2115,17 @@ def pcolor(self, *args, **kwargs):
21152115
# don't plot if C or any of the surrounding vertices are masked.
21162116
mask = ma.getmaskarray(C)[0:Nx-1,0:Ny-1]+xymask
21172117

2118-
verts = [ ( (X[i,j], Y[i,j]), (X[i+1,j], Y[i+1,j]),
2119-
(X[i+1,j+1], Y[i+1,j+1]), (X[i,j+1], Y[i,j+1]))
2120-
for i in range(Nx-1) for j in range(Ny-1) if not mask[i,j]]
2121-
2122-
C = array([C[i,j] for i in range(Nx-1) for j in range(Ny-1) if not mask[i,j]])
2118+
X1 = compress(ravel(mask==0),ravel(ma.filled(X[0:-1,0:-1])))
2119+
Y1 = compress(ravel(mask==0),ravel(ma.filled(Y[0:-1,0:-1])))
2120+
X2 = compress(ravel(mask==0),ravel(ma.filled(X[1:,0:-1])))
2121+
Y2 = compress(ravel(mask==0),ravel(ma.filled(Y[1:,0:-1])))
2122+
X3 = compress(ravel(mask==0),ravel(ma.filled(X[1:,1:])))
2123+
Y3 = compress(ravel(mask==0),ravel(ma.filled(Y[1:,1:])))
2124+
X4 = compress(ravel(mask==0),ravel(ma.filled(X[0:-1,1:])))
2125+
Y4 = compress(ravel(mask==0),ravel(ma.filled(Y[0:-1,1:])))
2126+
verts = zip(zip(X1,Y1),zip(X2,Y2),zip(X3,Y3),zip(X4,Y4))
2127+
2128+
C = compress(ravel(mask==0),ravel(ma.filled(C[0:Nx-1,0:Ny-1])))
21232129

21242130
if shading == 'faceted':
21252131
edgecolors = (0,0,0,1),
@@ -2146,7 +2152,7 @@ def pcolor(self, *args, **kwargs):
21462152
self.grid(False)
21472153

21482154
x = X.compressed()
2149-
y = X.compressed()
2155+
y = Y.compressed()
21502156
minx = amin(x)
21512157
maxx = amax(x)
21522158
miny = amin(y)

0 commit comments

Comments
 (0)
0