Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c4b8fe6

Browse files
authored
Merge pull request #8014 from dani-l/poly3dbug
do not ignore "closed" parameter in Poly3DCollection
2 parents 07752de + 2f568c7 commit c4b8fe6

File tree

5 files changed

+331
-3
lines changed

5 files changed

+331
-3
lines changed

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,8 @@ def set_verts(self, verts, closed=True):
589589
'''Set 3D vertices.'''
590590
self.get_vector(verts)
591591
# 2D verts will be updated at draw time
592-
PolyCollection.set_verts(self, [], closed)
592+
PolyCollection.set_verts(self, [], False)
593+
self._closed = closed
593594

594595
def set_verts_and_codes(self, verts, codes):
595596
'''Sets 3D vertices with path codes'''
@@ -654,7 +655,7 @@ def do_3d_projection(self, renderer):
654655
codes = [self._codes3d[idx] for z, s, fc, ec, idx in z_segments_2d]
655656
PolyCollection.set_verts_and_codes(self, segments_2d, codes)
656657
else:
657-
PolyCollection.set_verts(self, segments_2d)
658+
PolyCollection.set_verts(self, segments_2d, self._closed)
658659

659660
self._facecolors2d = [fc for z, s, fc, ec, idx in z_segments_2d]
660661
if len(self._edgecolors3d) == len(cface):
Binary file not shown.
Lines changed: 311 additions & 0 deletions
Loading

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from mpl_toolkits.mplot3d import Axes3D, axes3d, proj3d
3+
from mpl_toolkits.mplot3d import Axes3D, axes3d, proj3d, art3d
44
from matplotlib import cm
55
from matplotlib.testing.decorators import image_comparison
66
from matplotlib.collections import LineCollection
@@ -312,6 +312,22 @@ def test_quiver3d_pivot_tail():
312312
ax.quiver(x, y, z, u, v, w, length=0.1, pivot='tail', normalize=True)
313313

314314

315+
@image_comparison(baseline_images=['poly3dcollection_closed'],
316+
remove_text=True)
317+
def test_poly3dcollection_closed():
318+
fig = plt.figure()
319+
ax = fig.gca(projection='3d')
320+
321+
poly1 = np.array([[0, 0, 1], [0, 1, 1], [0, 0, 0]], np.float)
322+
poly2 = np.array([[0, 1, 1], [1, 1, 1], [1, 1, 0]], np.float)
323+
c1 = art3d.Poly3DCollection([poly1], linewidths=3, edgecolor='k',
324+
facecolor=(0.5, 0.5, 1, 0.5), closed=True)
325+
c2 = art3d.Poly3DCollection([poly2], linewidths=3, edgecolor='k',
326+
facecolor=(1, 0.5, 0.5, 0.5), closed=False)
327+
ax.add_collection3d(c1)
328+
ax.add_collection3d(c2)
329+
330+
315331
@image_comparison(baseline_images=['axes3d_labelpad'], extensions=['png'])
316332
def test_axes3d_labelpad():
317333
from matplotlib import rcParams

0 commit comments

Comments
 (0)