Skip to content

Commit d156771

Browse files
authored
Merge pull request #20416 from slavoutich/fix/patch3dcollection_z_marker_idx_missing
Fix missing Patch3DCollection._z_markers_idx
2 parents c64e8bb + e3caacd commit d156771

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ def set_3d_properties(self, zs, zdir):
462462
xs = []
463463
ys = []
464464
self._offsets3d = juggle_axes(xs, ys, np.atleast_1d(zs), zdir)
465+
self._z_markers_idx = slice(-1)
465466
self._vzs = None
466467
self.stale = True
467468

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -601,22 +601,26 @@ def test_patch_modification():
601601
@check_figures_equal(extensions=['png'])
602602
def test_patch_collection_modification(fig_test, fig_ref):
603603
# Test that modifying Patch3DCollection properties after creation works.
604-
patch = Circle((0, 0), 0.05)
605-
c = art3d.Patch3DCollection([patch], linewidths=3)
604+
patch1 = Circle((0, 0), 0.05)
605+
patch2 = Circle((0.1, 0.1), 0.03)
606+
facecolors = np.array([[0., 0.5, 0., 1.], [0.5, 0., 0., 0.5]])
607+
c = art3d.Patch3DCollection([patch1, patch2], linewidths=3)
606608

607609
ax_test = fig_test.add_subplot(projection='3d')
608610
ax_test.add_collection3d(c)
609611
c.set_edgecolor('C2')
610-
c.set_facecolor('C3')
612+
c.set_facecolor(facecolors)
611613
c.set_alpha(0.7)
612614
assert c.get_depthshade()
613615
c.set_depthshade(False)
614616
assert not c.get_depthshade()
615617

616-
patch = Circle((0, 0), 0.05)
617-
c = art3d.Patch3DCollection([patch], linewidths=3,
618-
edgecolor='C2', facecolor='C3', alpha=0.7,
619-
depthshade=False)
618+
patch1 = Circle((0, 0), 0.05)
619+
patch2 = Circle((0.1, 0.1), 0.03)
620+
facecolors = np.array([[0., 0.5, 0., 1.], [0.5, 0., 0., 0.5]])
621+
c = art3d.Patch3DCollection([patch1, patch2], linewidths=3,
622+
edgecolor='C2', facecolor=facecolors,
623+
alpha=0.7, depthshade=False)
620624

621625
ax_ref = fig_ref.add_subplot(projection='3d')
622626
ax_ref.add_collection3d(c)

0 commit comments

Comments
 (0)