Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1fd71a5

Browse filesBrowse files
authored
Merge pull request #23562 from oscargus/fixgetcolors
Fix issue with get_edgecolor and get_facecolor in 3D plots
2 parents f791518 + 1868c05 commit 1fd71a5
Copy full SHA for 1fd71a5

File tree

Expand file treeCollapse file tree

2 files changed

+32
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+32
-0
lines changed

‎lib/mpl_toolkits/mplot3d/art3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/art3d.py
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,9 +868,19 @@ def set_alpha(self, alpha):
868868
self.stale = True
869869

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

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

876886

‎lib/mpl_toolkits/tests/test_mplot3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/tests/test_mplot3d.py
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,6 +1840,28 @@ def test_scatter_spiral():
18401840
fig.canvas.draw()
18411841

18421842

1843+
def test_Poly3DCollection_get_facecolor():
1844+
# Smoke test to see that get_facecolor does not raise
1845+
# See GH#4067
1846+
y, x = np.ogrid[1:10:100j, 1:10:100j]
1847+
z2 = np.cos(x) ** 3 - np.sin(y) ** 2
1848+
fig = plt.figure()
1849+
ax = fig.add_subplot(111, projection='3d')
1850+
r = ax.plot_surface(x, y, z2, cmap='hot')
1851+
r.get_facecolor()
1852+
1853+
1854+
def test_Poly3DCollection_get_edgecolor():
1855+
# Smoke test to see that get_edgecolor does not raise
1856+
# See GH#4067
1857+
y, x = np.ogrid[1:10:100j, 1:10:100j]
1858+
z2 = np.cos(x) ** 3 - np.sin(y) ** 2
1859+
fig = plt.figure()
1860+
ax = fig.add_subplot(111, projection='3d')
1861+
r = ax.plot_surface(x, y, z2, cmap='hot')
1862+
r.get_edgecolor()
1863+
1864+
18431865
@pytest.mark.parametrize(
18441866
"vertical_axis, proj_expected, axis_lines_expected, tickdirs_expected",
18451867
[

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.