@@ -3426,18 +3426,23 @@ def _apply_boxplot(
34263426 # Call function
34273427 x , y , kw = self ._parse_plot1d (x , y , autoy = False , autoguide = False , vert = vert , ** kw ) # noqa: E501
34283428 kw .setdefault ('positions' , x )
3429- obj = self ._plot_native ('boxplot' , y , vert = vert , ** kw )
3429+ artists = self ._plot_native ('boxplot' , y , vert = vert , ** kw )
34303430
34313431 # Modify artist settings
3432+ artists = artists or {} # necessary?
3433+ artists = {
3434+ key : cbook .silent_list (type (objs [0 ]).__name__ , objs ) if objs else objs
3435+ for key , objs in artists .items ()
3436+ }
34323437 for key , aprops in props .items ():
3433- if key not in obj : # possible if not rendered
3438+ if key not in artists : # possible if not rendered
34343439 continue
3435- artists = obj [key ]
3440+ objs = artists [key ]
34363441 if not isinstance (fillalpha , list ):
3437- fillalpha = [fillalpha ] * len (artists )
3442+ fillalpha = [fillalpha ] * len (objs )
34383443 if not isinstance (fillcolor , list ):
3439- fillcolor = [fillcolor ] * len (artists )
3440- for i , artist in enumerate (artists ):
3444+ fillcolor = [fillcolor ] * len (objs )
3445+ for i , obj in enumerate (objs ):
34413446 # Update lines used for boxplot components
34423447 # TODO: Test this thoroughly!
34433448 iprops = {
@@ -3448,14 +3453,14 @@ def _apply_boxplot(
34483453 )
34493454 for key , value in aprops .items ()
34503455 }
3451- artist .update (iprops )
3456+ obj .update (iprops )
34523457 # "Filled" boxplot by adding patch beneath line path
34533458 if key == 'boxes' :
34543459 ifillcolor = fillcolor [i ] # must stay within the if statement
34553460 ifillalpha = fillalpha [i ]
34563461 if ifillcolor is not None or ifillalpha is not None :
34573462 patch = mpatches .PathPatch (
3458- artist .get_path (),
3463+ obj .get_path (),
34593464 linewidth = 0 ,
34603465 facecolor = ifillcolor ,
34613466 alpha = ifillalpha ,
@@ -3464,11 +3469,11 @@ def _apply_boxplot(
34643469 # Outlier markers
34653470 if key == 'fliers' :
34663471 if marker is not None :
3467- artist .set_marker (marker )
3472+ obj .set_marker (marker )
34683473 if markersize is not None :
3469- artist .set_markersize (markersize )
3474+ obj .set_markersize (markersize )
34703475
3471- return obj
3476+ return artists
34723477
34733478 @docstring ._snippet_manager
34743479 def box (self , * args , ** kwargs ):
@@ -3529,29 +3534,33 @@ def _apply_violinplot(self, x, y, vert=True, **kwargs):
35293534 kw .pop ('labels' , None ) # already applied in _parse_plot1d
35303535 kw .setdefault ('positions' , x )
35313536 y = _not_none (kw .pop ('distribution' ), y ) # might not have reduced the data
3532- obj = self ._plot_native (
3537+ artists = self ._plot_native (
35333538 'violinplot' , y , vert = vert ,
35343539 showmeans = False , showmedians = False , showextrema = False , ** kw
35353540 )
35363541
35373542 # Modify body settings
3538- artists = (obj or {}).get ('bodies' , ())
3543+ artists = artists or {} # necessary?
3544+ artists = {
3545+ key : cbook .silent_list (type (objs [0 ]).__name__ , objs ) if objs else objs
3546+ for key , objs in artists .items ()
3547+ }
3548+ bodies = artists .get ('bodies' , ())
35393549 if not isinstance (fillalpha , list ):
3540- fillalpha = [fillalpha ] * len (artists )
3550+ fillalpha = [fillalpha ] * len (bodies )
35413551 if not isinstance (fillcolor , list ):
3542- fillcolor = [fillcolor ] * len (artists )
3552+ fillcolor = [fillcolor ] * len (bodies )
35433553 if not isinstance (edgecolor , list ):
3544- edgecolor = [edgecolor ] * len (artists )
3545- for i , artist in enumerate (artists ):
3546- artist .set_linewidths (linewidth )
3554+ edgecolor = [edgecolor ] * len (bodies )
3555+ for i , body in enumerate (bodies ):
3556+ body .set_linewidths (linewidth )
35473557 if fillalpha [i ] is not None :
3548- artist .set_alpha (fillalpha [i ])
3558+ body .set_alpha (fillalpha [i ])
35493559 if fillcolor [i ] is not None :
3550- artist .set_facecolor (fillcolor [i ])
3560+ body .set_facecolor (fillcolor [i ])
35513561 if edgecolor [i ] is not None :
3552- artist .set_edgecolor (edgecolor [i ])
3553-
3554- return obj
3562+ body .set_edgecolor (edgecolor [i ])
3563+ return artists
35553564
35563565 @docstring ._snippet_manager
35573566 def violin (self , * args , ** kwargs ):
0 commit comments