Skip to content

Commit ba0ea86

Browse files
authored
Merge pull request #13573 from jklymak/fix-mplot3d-transparency
Fix mplot3d transparency
2 parents f8d02b9 + 8b67728 commit ba0ea86

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

lib/mpl_toolkits/mplot3d/art3d.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ def set_alpha(self, alpha):
758758
raise TypeError('alpha must be a float or None')
759759
artist.Artist.set_alpha(self, alpha)
760760
try:
761-
self._facecolors = mcolors.to_rgba_array(
761+
self._facecolors3d = mcolors.to_rgba_array(
762762
self._facecolors3d, self._alpha)
763763
except (AttributeError, TypeError, IndexError):
764764
pass

lib/mpl_toolkits/tests/test_mplot3d.py

+18
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,24 @@ def test_poly_collection_2d_to_3d_empty():
454454
assert poly.get_paths() == []
455455

456456

457+
@image_comparison(baseline_images=['poly3dcollection_alpha'],
458+
remove_text=True, extensions=['png'])
459+
def test_poly3dcollection_alpha():
460+
fig = plt.figure()
461+
ax = fig.gca(projection='3d')
462+
463+
poly1 = np.array([[0, 0, 1], [0, 1, 1], [0, 0, 0]], float)
464+
poly2 = np.array([[0, 1, 1], [1, 1, 1], [1, 1, 0]], float)
465+
c1 = art3d.Poly3DCollection([poly1], linewidths=3, edgecolor='k',
466+
facecolor=(0.5, 0.5, 1), closed=True)
467+
c1.set_alpha(0.5)
468+
c2 = art3d.Poly3DCollection([poly2], linewidths=3, edgecolor='k',
469+
facecolor=(1, 0.5, 0.5), closed=False)
470+
c2.set_alpha(0.5)
471+
ax.add_collection3d(c1)
472+
ax.add_collection3d(c2)
473+
474+
457475
@image_comparison(baseline_images=['axes3d_labelpad'], extensions=['png'])
458476
def test_axes3d_labelpad():
459477
from matplotlib import rcParams

0 commit comments

Comments
 (0)