Skip to content

Commit 8b08be3

Browse files
committed
Fix issue with get_edgecolor and get_facecolor
1 parent 29a8663 commit 8b08be3

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

lib/mpl_toolkits/mplot3d/art3d.py

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

869869
def get_facecolor(self):
870+
# docstring inherited
871+
# self._facecolors2d is not initialized until do_3d_projection
872+
if not hasattr(self, '_facecolors2d'):
873+
self.axes.M = self.axes.get_proj()
874+
self.do_3d_projection()
870875
return self._facecolors2d
871876

872877
def get_edgecolor(self):
878+
# docstring inherited
879+
# self._edgecolors2d is not initialized until do_3d_projection
880+
if not hasattr(self, '_edgecolors2d'):
881+
self.axes.M = self.axes.get_proj()
882+
self.do_3d_projection()
873883
return self._edgecolors2d
874884

875885

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_facecolor does not 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_facecolor()
1824+
1825+
1826+
def test_Poly3DCollection_get_edgecolors():
1827+
# Smoke test to see that get_edgecolor does not 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_edgecolor()
1835+
1836+
18151837
@pytest.mark.parametrize(
18161838
"vertical_axis, proj_expected, axis_lines_expected, tickdirs_expected",
18171839
[

0 commit comments

Comments
 (0)