From: <he...@us...> - 2009-07-14 21:11:59
|
Revision: 7260 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7260&view=rev Author: heeres Date: 2009-07-14 21:11:53 +0000 (Tue, 14 Jul 2009) Log Message: ----------- Fix mplot3d bug with empty lists thanks to Ryan Wagner. Modified Paths: -------------- trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py Modified: trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py =================================================================== --- trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py 2009-07-14 19:21:47 UTC (rev 7259) +++ trunk/matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py 2009-07-14 21:11:53 UTC (rev 7260) @@ -633,11 +633,14 @@ shade = np.array(shade) mask = ~np.isnan(shade) - norm = Normalize(min(shade[mask]), max(shade[mask])) - color = color.copy() - color[3] = 1 - colors = [color * (0.5 + norm(v) * 0.5) for v in shade] + if len(shade[mask]) > 0: + norm = Normalize(min(shade[mask]), max(shade[mask])) + color = color.copy() + color[3] = 1 + colors = [color * (0.5 + norm(v) * 0.5) for v in shade] + else: + colors = color.copy() return colors @@ -707,6 +710,12 @@ polyverts = [] normals = [] nsteps = round(len(topverts[0]) / stride) + if nsteps <= 1: + if len(topverts[0]) > 1: + nsteps = 2 + else: + continue + stepsize = (len(topverts[0]) - 1) / (nsteps - 1) for i in range(int(round(nsteps)) - 1): i1 = int(round(i * stepsize)) @@ -719,11 +728,11 @@ v1 = np.array(topverts[0][i1]) - np.array(topverts[0][i2]) v2 = np.array(topverts[0][i1]) - np.array(botverts[0][i1]) normals.append(np.cross(v1, v2)) - + colors = self._shade_colors(color, normals) colors2 = self._shade_colors(color, normals) polycol = art3d.Poly3DCollection(polyverts, facecolors=colors, - edgecolors=colors2) + edgecolors=colors2) self.add_collection3d(polycol) for col in colls: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |