@@ -243,19 +243,9 @@ def test_scatter3d_color():
243243 color = 'b' , marker = 's' )
244244
245245
246- def test_scatter3d_depthshade_false ():
247- """
248- Test that 3d scatter plot doesn't throw
249- IndexError with depthshade=False (issue #18037)
250- """
251- x = y = z = np .arange (16 )
252- fig_test = plt .figure ()
253- ax_test = fig_test .add_subplot (projection = '3d' )
254- ax_test .scatter (x , y , z , depthshade = False )
255-
256-
246+ @pytest .mark .parametrize ('depthshade' , [True , False ])
257247@check_figures_equal (extensions = ['png' ])
258- def test_scatter3d_sorting (fig_ref , fig_test ):
248+ def test_scatter3d_sorting (fig_ref , fig_test , depthshade ):
259249 """Test that marker properties are correctly sorted."""
260250
261251 y , x = np .mgrid [:10 , :10 ]
@@ -289,10 +279,19 @@ def test_scatter3d_sorting(fig_ref, fig_test):
289279 (edgecolors != ec )
290280 )
291281 subset = np .ma .masked_array (z , subset , dtype = float )
292- ax_ref .scatter (x , y , subset , s = s , fc = fc , ec = ec , alpha = 1 )
282+
283+ # When depth shading is disabled, the colors are passed through as
284+ # single-item lists; this triggers single path optimization. The
285+ # following reshaping is a hack to disable that, since the optimization
286+ # would not occur for the full scatter which has multiple colors.
287+ fc = np .repeat (fc , sum (~ subset .mask ))
288+
289+ ax_ref .scatter (x , y , subset , s = s , fc = fc , ec = ec , alpha = 1 ,
290+ depthshade = depthshade )
293291
294292 ax_test = fig_test .gca (projection = '3d' )
295- ax_test .scatter (x , y , z , s = sizes , fc = facecolors , ec = edgecolors , alpha = 1 )
293+ ax_test .scatter (x , y , z , s = sizes , fc = facecolors , ec = edgecolors , alpha = 1 ,
294+ depthshade = depthshade )
296295
297296
298297@pytest .mark .parametrize ('azim' , [- 50 , 130 ]) # yellow first, blue first
0 commit comments