Hello, I have been noticing odd behaviors when plotting polygons and surfaces using mplot3d. Some polygon faces were being slightly transparent, for example when you rotate the sphere in the 'surface3d_demo2.py' example. Some faces were completely missing, for example in the 'hist3d_demo.py' example. In the surface3d_demo3.py example, I wasn't fully happy with the appearance of the plot and I was fairly sure it wasn't 100% correct.
I believe I have the problem tracked down to the "_shade_colors()" method in axes3d.py. I have a patch and it needs to be applied to both the development branch and one for the release candidate. However, I am almost certain that it could break some others 3d display code and I would like people to check it out first before it gets applied. The 'mplot3d_vectshade.patch' can be used against the current development branch, while 'mplot3d_vectshade_rc2.patch' can be used against the latest in the maintenance branch. Thanks, and I would greatly appreciate your input! Ben Root
Index: lib/mpl_toolkits/mplot3d/axes3d.py =================================================================== --- lib/mpl_toolkits/mplot3d/axes3d.py (revision 8898) +++ lib/mpl_toolkits/mplot3d/axes3d.py (working copy) @@ -818,13 +818,13 @@ if len(shade[mask]) > 0: norm = Normalize(min(shade[mask]), max(shade[mask])) - if art3d.iscolor(color): - color = color.copy() - color[3] = 1 - colors = np.outer(0.5 + norm(shade) * 0.5, color) - else: - colors = colorConverter.to_rgba_array(color) * \ - (0.5 + 0.5 * norm(shade)[:, np.newaxis]) + color = colorConverter.to_rgba_array(color) + # shape of color should be (M, 4) (where M is number of faces) + # shape of shade should be (M,) + # colors should have final shape of (M, 4) + alpha = color[:, 3] + colors = (0.5 + norm(shade)[:, np.newaxis] * 0.5) * color + colors[:, 3] = alpha else: colors = color.copy()
Index: lib/mpl_toolkits/mplot3d/axes3d.py =================================================================== --- lib/mpl_toolkits/mplot3d/axes3d.py (revision 8900) +++ lib/mpl_toolkits/mplot3d/axes3d.py (working copy) @@ -782,14 +782,13 @@ if len(shade[mask]) > 0: norm = Normalize(min(shade[mask]), max(shade[mask])) - if art3d.iscolor(color): - color = color.copy() - color[3] = 1 - colors = [color * (0.5 + norm(v) * 0.5) for v in shade] - else: - colors = [np.array(colorConverter.to_rgba(c)) * \ - (0.5 + norm(v) * 0.5) \ - for c, v in zip(color, shade)] + color = colorConverter.to_rgba_array(color) + # shape of color should be (M, 4) (where M is number of faces) + # shape of shade should be (M,) + # colors should have final shape of (M, 4) + alpha = color[:, 3] + colors = (0.5 + norm(shade)[:, np.newaxis] * 0.5) * color + colors[:, 3] = alpha else: colors = color.copy()
------------------------------------------------------------------------------ Gaining the trust of online customers is vital for the success of any company that requires sensitive data to be transmitted over the Web. Learn how to best implement a security strategy that keeps consumers' information secure and instills the confidence they need to proceed with transactions. http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel