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

Skip to content

Commit 9ca7245

Browse files
authored
Merge pull request #18162 from meeseeksmachine/auto-backport-of-pr-18156-on-v3.3.x
Backport PR #18156 on branch v3.3.x (Fix IndexError when using scatter3d and depthshade=False)
2 parents 6a6c6d1 + f132151 commit 9ca7245

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,9 @@ def do_3d_projection(self, renderer):
507507
vzs = vzs[z_markers_idx]
508508
vxs = vxs[z_markers_idx]
509509
vys = vys[z_markers_idx]
510-
fcs = fcs[z_markers_idx]
511-
ecs = ecs[z_markers_idx]
510+
if self._depthshade:
511+
fcs = fcs[z_markers_idx]
512+
ecs = ecs[z_markers_idx]
512513
if len(sizes) > 1:
513514
sizes = sizes[z_markers_idx]
514515
vps = np.column_stack((vxs, vys))

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,17 @@ def test_scatter3d_color():
242242
color='b', marker='s')
243243

244244

245+
def test_scatter3d_depthshade_false():
246+
"""
247+
Test that 3d scatter plot doesn't throw
248+
IndexError with depthshade=False (issue #18037)
249+
"""
250+
x = y = z = np.arange(16)
251+
fig_test = plt.figure()
252+
ax_test = fig_test.add_subplot(projection='3d')
253+
ax_test.scatter(x, y, z, depthshade=False)
254+
255+
245256
@check_figures_equal(extensions=['png'])
246257
def test_scatter3d_size(fig_ref, fig_test):
247258
"""Test that large markers in correct position (issue #18135)"""

0 commit comments

Comments
 (0)