@@ -239,8 +239,11 @@ def test_scatter3d_color():
239239 ax = fig .add_subplot (111 , projection = '3d' )
240240 ax .scatter (np .arange (10 ), np .arange (10 ), np .arange (10 ),
241241 color = 'r' , marker = 'o' )
242- ax .scatter (np .arange (10 , 20 ), np .arange (10 , 20 ), np .arange (10 , 20 ),
243- color = 'b' , marker = 's' )
242+ c = ax .scatter (np .arange (10 , 20 ), np .arange (10 , 20 ), np .arange (10 , 20 ),
243+ color = 'g' , marker = 's' )
244+ # Changing the collection after the fact should work correctly.
245+ c .set_facecolor ('b' )
246+ c .set_edgecolor ('b' )
244247
245248
246249@pytest .mark .parametrize ('depthshade' , [True , False ])
@@ -526,6 +529,25 @@ def test_quiver3d_masked():
526529 ax .quiver (x , y , z , u , v , w , length = 0.1 , pivot = 'tip' , normalize = True )
527530
528531
532+ @check_figures_equal (extensions = ['png' ])
533+ def test_patch_collection_modification (fig_test , fig_ref ):
534+ # Test that modifying Patch3DCollection properties after creation works.
535+ patch = Circle ((0 , 0 ), 0.05 )
536+ c = art3d .Patch3DCollection ([patch ], linewidths = 3 )
537+
538+ ax_test = fig_test .add_subplot (projection = '3d' )
539+ ax_test .add_collection3d (c )
540+ c .set_edgecolor ('C2' )
541+ c .set_facecolor ('C3' )
542+
543+ patch = Circle ((0 , 0 ), 0.05 )
544+ c = art3d .Patch3DCollection ([patch ], linewidths = 3 ,
545+ edgecolor = 'C2' , facecolor = 'C3' )
546+
547+ ax_ref = fig_ref .add_subplot (projection = '3d' )
548+ ax_ref .add_collection3d (c )
549+
550+
529551@mpl3d_image_comparison (['poly3dcollection_closed.png' ])
530552def test_poly3dcollection_closed ():
531553 fig = plt .figure ()
@@ -558,8 +580,10 @@ def test_poly3dcollection_alpha():
558580 c1 = art3d .Poly3DCollection ([poly1 ], linewidths = 3 , edgecolor = 'k' ,
559581 facecolor = (0.5 , 0.5 , 1 ), closed = True )
560582 c1 .set_alpha (0.5 )
561- c2 = art3d .Poly3DCollection ([poly2 ], linewidths = 3 , edgecolor = 'k' ,
562- facecolor = (1 , 0.5 , 0.5 ), closed = False )
583+ c2 = art3d .Poly3DCollection ([poly2 ], linewidths = 3 , closed = False )
584+ # Post-creation modification should work.
585+ c2 .set_facecolor ((1 , 0.5 , 0.5 ))
586+ c2 .set_edgecolor ('k' )
563587 c2 .set_alpha (0.5 )
564588 ax .add_collection3d (c1 )
565589 ax .add_collection3d (c2 )
0 commit comments