@@ -243,6 +243,20 @@ def test_scatter3d_color():
243243 color = 'b' , marker = 's' )
244244
245245
246+ @check_figures_equal (extensions = ['png' ])
247+ def test_scatter3d_modification (fig_ref , fig_test ):
248+ # Changing Path3DCollection properties post-creation should work correctly.
249+ ax_test = fig_test .add_subplot (projection = '3d' )
250+ c = ax_test .scatter (np .arange (10 ), np .arange (10 ), np .arange (10 ),
251+ marker = 'o' )
252+ c .set_facecolor ('C1' )
253+ c .set_edgecolor ('C2' )
254+
255+ ax_ref = fig_ref .add_subplot (projection = '3d' )
256+ ax_ref .scatter (np .arange (10 ), np .arange (10 ), np .arange (10 ), marker = 'o' ,
257+ facecolor = 'C1' , edgecolor = 'C2' )
258+
259+
246260@pytest .mark .parametrize ('depthshade' , [True , False ])
247261@check_figures_equal (extensions = ['png' ])
248262def test_scatter3d_sorting (fig_ref , fig_test , depthshade ):
@@ -526,6 +540,25 @@ def test_quiver3d_masked():
526540 ax .quiver (x , y , z , u , v , w , length = 0.1 , pivot = 'tip' , normalize = True )
527541
528542
543+ @check_figures_equal (extensions = ['png' ])
544+ def test_patch_collection_modification (fig_test , fig_ref ):
545+ # Test that modifying Patch3DCollection properties after creation works.
546+ patch = Circle ((0 , 0 ), 0.05 )
547+ c = art3d .Patch3DCollection ([patch ], linewidths = 3 )
548+
549+ ax_test = fig_test .add_subplot (projection = '3d' )
550+ ax_test .add_collection3d (c )
551+ c .set_edgecolor ('C2' )
552+ c .set_facecolor ('C3' )
553+
554+ patch = Circle ((0 , 0 ), 0.05 )
555+ c = art3d .Patch3DCollection ([patch ], linewidths = 3 ,
556+ edgecolor = 'C2' , facecolor = 'C3' )
557+
558+ ax_ref = fig_ref .add_subplot (projection = '3d' )
559+ ax_ref .add_collection3d (c )
560+
561+
529562@mpl3d_image_comparison (['poly3dcollection_closed.png' ])
530563def test_poly3dcollection_closed ():
531564 fig = plt .figure ()
@@ -558,8 +591,10 @@ def test_poly3dcollection_alpha():
558591 c1 = art3d .Poly3DCollection ([poly1 ], linewidths = 3 , edgecolor = 'k' ,
559592 facecolor = (0.5 , 0.5 , 1 ), closed = True )
560593 c1 .set_alpha (0.5 )
561- c2 = art3d .Poly3DCollection ([poly2 ], linewidths = 3 , edgecolor = 'k' ,
562- facecolor = (1 , 0.5 , 0.5 ), closed = False )
594+ c2 = art3d .Poly3DCollection ([poly2 ], linewidths = 3 , closed = False )
595+ # Post-creation modification should work.
596+ c2 .set_facecolor ((1 , 0.5 , 0.5 ))
597+ c2 .set_edgecolor ('k' )
563598 c2 .set_alpha (0.5 )
564599 ax .add_collection3d (c1 )
565600 ax .add_collection3d (c2 )
0 commit comments