diff --git a/lib/mpl_toolkits/mplot3d/art3d.py b/lib/mpl_toolkits/mplot3d/art3d.py index d38fa862b69e..c8b068165f7b 100644 --- a/lib/mpl_toolkits/mplot3d/art3d.py +++ b/lib/mpl_toolkits/mplot3d/art3d.py @@ -758,7 +758,7 @@ def set_alpha(self, alpha): raise TypeError('alpha must be a float or None') artist.Artist.set_alpha(self, alpha) try: - self._facecolors = mcolors.to_rgba_array( + self._facecolors3d = mcolors.to_rgba_array( self._facecolors3d, self._alpha) except (AttributeError, TypeError, IndexError): pass diff --git a/lib/mpl_toolkits/tests/baseline_images/test_mplot3d/poly3dcollection_alpha.png b/lib/mpl_toolkits/tests/baseline_images/test_mplot3d/poly3dcollection_alpha.png new file mode 100644 index 000000000000..6081c5a7e19c Binary files /dev/null and b/lib/mpl_toolkits/tests/baseline_images/test_mplot3d/poly3dcollection_alpha.png differ diff --git a/lib/mpl_toolkits/tests/test_mplot3d.py b/lib/mpl_toolkits/tests/test_mplot3d.py index 92b4031a6e85..57998c36dcf4 100644 --- a/lib/mpl_toolkits/tests/test_mplot3d.py +++ b/lib/mpl_toolkits/tests/test_mplot3d.py @@ -454,6 +454,24 @@ def test_poly_collection_2d_to_3d_empty(): assert poly.get_paths() == [] +@image_comparison(baseline_images=['poly3dcollection_alpha'], + remove_text=True, extensions=['png']) +def test_poly3dcollection_alpha(): + fig = plt.figure() + ax = fig.gca(projection='3d') + + poly1 = np.array([[0, 0, 1], [0, 1, 1], [0, 0, 0]], float) + poly2 = np.array([[0, 1, 1], [1, 1, 1], [1, 1, 0]], float) + c1 = art3d.Poly3DCollection([poly1], linewidths=3, edgecolor='k', + facecolor=(0.5, 0.5, 1), closed=True) + c1.set_alpha(0.5) + c2 = art3d.Poly3DCollection([poly2], linewidths=3, edgecolor='k', + facecolor=(1, 0.5, 0.5), closed=False) + c2.set_alpha(0.5) + ax.add_collection3d(c1) + ax.add_collection3d(c2) + + @image_comparison(baseline_images=['axes3d_labelpad'], extensions=['png']) def test_axes3d_labelpad(): from matplotlib import rcParams