Hi All,
I've attached a patch which addresses two small issues. The first is a
bug in patches.py. When doing 3d scatter plots
xs, ys = zip(*self.xy) (line 480)
crashes, as the right hand side expands to 3 values.
The other is a speedup, normalising an entire array at once, rather
than element by element, speeding up the attached script by a factor
of 6x (and upgrading my actual application from 'too slow' to 'quite
reasonable' :-)
Cheers,
Tim
Index: lib/matplotlib/art3d.py
===================================================================
--- lib/matplotlib/art3d.py (revision 3193)
+++ lib/matplotlib/art3d.py (working copy)
@@ -369,7 +369,7 @@
"""Modify the alphas of the color list according to depth"""
colors = get_colors(colors,len(zs))
norm = Normalize(min(zs),max(zs))
- sats = nx.array([1-norm(z)*0.7 for z in zs])
+ sats = 1 - norm(zs)*0.7
colors = [(c[0],c[1],c[2],c[3]*s) for c,s in zip(colors,sats)]
return colors
Index: lib/matplotlib/patches.py
===================================================================
--- lib/matplotlib/patches.py (revision 3193)
+++ lib/matplotlib/patches.py (working copy)
@@ -480,7 +480,7 @@
def get_verts(self):
- xs, ys = zip(*self.xy)
+ xs, ys = zip(*self.xy)[:2]
xs = self.convert_xunits(xs)
ys = self.convert_yunits(ys)
return zip(xs, ys)
import random
import pylab as p
import matplotlib.axes3d as p3
def main():
fig = p.figure()
ax = p3.Axes3D(fig)
pts = 7500
X = range(pts)
Y = range(pts)
Z = range(pts)
ax.scatter3D(X, Y, Z)
p.savefig("tmp.png")
if __name__ == '__main__':
import hotshot, hotshot.stats
prof = hotshot.Profile("stones.prof")
benchtime = prof.runcall(main)
prof.close()
stats = hotshot.stats.load("stones.prof")
stats.strip_dirs()
stats.sort_stats('cumulative', 'calls')
stats.print_stats(20)
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel