Skip to content

Commit 41543cd

Browse files
committed
Fixing polygon shading in mplot3d and simultaneously allowing users to specify alpha values for 3d polygons.
(Shading calculation was applied to the rgba array instead of just rgb) svn path=/trunk/matplotlib/; revision=8930
1 parent 568630d commit 41543cd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -818,13 +818,13 @@ def _shade_colors(self, color, normals):
818818

819819
if len(shade[mask]) > 0:
820820
norm = Normalize(min(shade[mask]), max(shade[mask]))
821-
if art3d.iscolor(color):
822-
color = color.copy()
823-
color[3] = 1
824-
colors = np.outer(0.5 + norm(shade) * 0.5, color)
825-
else:
826-
colors = colorConverter.to_rgba_array(color) * \
827-
(0.5 + 0.5 * norm(shade)[:, np.newaxis])
821+
color = colorConverter.to_rgba_array(color)
822+
# shape of color should be (M, 4) (where M is number of faces)
823+
# shape of shade should be (M,)
824+
# colors should have final shape of (M, 4)
825+
alpha = color[:, 3]
826+
colors = (0.5 + norm(shade)[:, np.newaxis] * 0.5) * color
827+
colors[:, 3] = alpha
828828
else:
829829
colors = color.copy()
830830

0 commit comments

Comments
 (0)