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 96180ad

Browse filesBrowse files
returning _facecolor2d and _edgecolor2d as arrays
When using Poly3dCollection, returned colors for _edgecolor2d and _facecolor2d colors are tuples. By returning these asarrays we make sure they have the .size in HandlerPolyCollection. Also added a test case that would fail without this fix Co-authored-by: Oscar Gustafsson Co-authored-by: Chahak Mehta <201501422@daiict.ac.in>
1 parent 6767738 commit 96180ad
Copy full SHA for 96180ad

File tree

Expand file treeCollapse file tree

2 files changed

+15
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+15
-2
lines changed

‎lib/mpl_toolkits/mplot3d/art3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/art3d.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,15 +1063,15 @@ def get_facecolor(self):
10631063
if not hasattr(self, '_facecolors2d'):
10641064
self.axes.M = self.axes.get_proj()
10651065
self.do_3d_projection()
1066-
return self._facecolors2d
1066+
return np.asarray(self._facecolors2d)
10671067

10681068
def get_edgecolor(self):
10691069
# docstring inherited
10701070
# self._edgecolors2d is not initialized until do_3d_projection
10711071
if not hasattr(self, '_edgecolors2d'):
10721072
self.axes.M = self.axes.get_proj()
10731073
self.do_3d_projection()
1074-
return self._edgecolors2d
1074+
return np.asarray(self._edgecolors2d)
10751075

10761076

10771077
def poly_collection_2d_to_3d(col, zs=0, zdir='z'):

‎lib/mpl_toolkits/mplot3d/tests/test_legend3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/tests/test_legend3d.py
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,16 @@ def test_contourf_legend_elements():
106106
assert all(isinstance(a, Rectangle) for a in artists)
107107
assert all(same_color(a.get_facecolor(), c)
108108
for a, c in zip(artists, expected_colors))
109+
110+
111+
def test_legend_Poly3dCollection():
112+
113+
verts = np.asarray([[0, 0, 0], [0, 1, 1], [1, 0, 1]])
114+
mesh = art3d.Poly3DCollection([verts], label="surface")
115+
116+
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
117+
mesh.set_edgecolor('k')
118+
handle = ax.add_collection3d(mesh)
119+
leg = ax.legend()
120+
assert (leg.legend_handles[0].get_facecolor()
121+
== handle.get_facecolor()).all()

0 commit comments

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