Skip to content

Commit 859ff08

Browse files
committed
Fix issue with get_edgecolors and get_facecolors
1 parent 29a8663 commit 859ff08

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lib/mpl_toolkits/mplot3d/art3d.py

+6
Original file line numberDiff line numberDiff line change
@@ -867,9 +867,15 @@ def set_alpha(self, alpha):
867867
self.stale = True
868868

869869
def get_facecolor(self):
870+
if not hasattr(self, '_facecolors2d'):
871+
self.axes.M = self.axes.get_proj()
872+
self.do_3d_projection()
870873
return self._facecolors2d
871874

872875
def get_edgecolor(self):
876+
if not hasattr(self, '_edgecolors2d'):
877+
self.axes.M = self.axes.get_proj()
878+
self.do_3d_projection()
873879
return self._edgecolors2d
874880

875881

lib/mpl_toolkits/tests/test_mplot3d.py

+22
Original file line numberDiff line numberDiff line change
@@ -1812,6 +1812,28 @@ def test_scatter_spiral():
18121812
fig.canvas.draw()
18131813

18141814

1815+
def test_Poly3DCollection_get_facecolors():
1816+
# Smoke test to see that get_facecolors doesn't raise
1817+
# See GH#4067
1818+
y, x = np.ogrid[1:10:100j, 1:10:100j]
1819+
z2 = np.cos(x) ** 3 - np.sin(y) ** 2
1820+
fig = plt.figure()
1821+
ax = fig.add_subplot(111, projection='3d')
1822+
r = ax.plot_surface(x, y, z2, cmap='hot')
1823+
r.get_facecolors()
1824+
1825+
1826+
def test_Poly3DCollection_get_edgecolors():
1827+
# Smoke test to see that get_edgecolors doesn't raise
1828+
# See GH#4067
1829+
y, x = np.ogrid[1:10:100j, 1:10:100j]
1830+
z2 = np.cos(x) ** 3 - np.sin(y) ** 2
1831+
fig = plt.figure()
1832+
ax = fig.add_subplot(111, projection='3d')
1833+
r = ax.plot_surface(x, y, z2, cmap='hot')
1834+
r.get_edgecolors()
1835+
1836+
18151837
@pytest.mark.parametrize(
18161838
"vertical_axis, proj_expected, axis_lines_expected, tickdirs_expected",
18171839
[

0 commit comments

Comments
 (0)