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

Skip to content

Commit 524172f

Browse files
neil-ptrNeilzon Viloria
and
Neilzon Viloria
authored
Fix IndexError when using scatter3d and depthshade=False (#18156)
* Fix IndexError when using scatter3d and depthshade=False * flake8 compliance for test_mplot3d.py * change test_scatter3d_depthshade_false to figure comparison test * flake8 compliance in test_mplot3d.py * removed image and changed test_scatter3d_depthshade_false Co-authored-by: Neilzon Viloria <[email protected]>
1 parent df50f12 commit 524172f

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
@@ -508,8 +508,9 @@ def do_3d_projection(self, renderer):
508508
vzs = vzs[z_markers_idx]
509509
vxs = vxs[z_markers_idx]
510510
vys = vys[z_markers_idx]
511-
fcs = fcs[z_markers_idx]
512-
ecs = ecs[z_markers_idx]
511+
if self._depthshade:
512+
fcs = fcs[z_markers_idx]
513+
ecs = ecs[z_markers_idx]
513514
if len(sizes) > 1:
514515
sizes = sizes[z_markers_idx]
515516
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)