@@ -3821,7 +3821,7 @@ def apply_mask(arrays, mask):
38213821 @_api .rename_parameter ("3.9" , "labels" , "tick_labels" )
38223822 def boxplot (self , x , notch = None , sym = None , vert = None ,
38233823 orientation = 'vertical' , whis = None , positions = None ,
3824- widths = None , patch_artist = None , bootstrap = None ,
3824+ widths = None , patch_artist = 'auto' , bootstrap = None ,
38253825 usermedians = None , conf_intervals = None ,
38263826 meanline = None , showmeans = None , showcaps = None ,
38273827 showbox = None , showfliers = None , boxprops = None ,
@@ -3947,9 +3947,12 @@ def boxplot(self, x, notch=None, sym=None, vert=None,
39473947 The widths of the boxes. The default is 0.5, or ``0.15*(distance
39483948 between extreme positions)``, if that is smaller.
39493949
3950- patch_artist : bool, default: :rc:`boxplot.patchartist`
3951- If `False` produces boxes with the Line2D artist. Otherwise,
3952- boxes are drawn with Patch artists.
3950+ patch_artist : bool, default: 'auto'
3951+ If 'auto', boxes are drawn with the Patch artist if a parameter
3952+ that needs the Patch artist is passed, otherwise they are drawn
3953+ with the Line2D artist.
3954+ If `True` produces boxes with the Patch artist.
3955+ If `False` produces boxes with the Line2D artist.
39533956
39543957 tick_labels : list of str, optional
39553958 The tick labels of each boxplot.
@@ -4060,8 +4063,6 @@ def boxplot(self, x, notch=None, sym=None, vert=None,
40604063 labels = tick_labels , autorange = autorange )
40614064 if notch is None :
40624065 notch = mpl .rcParams ['boxplot.notch' ]
4063- if patch_artist is None :
4064- patch_artist = mpl .rcParams ['boxplot.patchartist' ]
40654066 if meanline is None :
40664067 meanline = mpl .rcParams ['boxplot.meanline' ]
40674068 if showmeans is None :
@@ -4086,7 +4087,12 @@ def boxplot(self, x, notch=None, sym=None, vert=None,
40864087 if flierprops is None :
40874088 flierprops = {}
40884089
4089- if patch_artist :
4090+ if patch_artist == 'auto' :
4091+ patch_artist = mpl .rcParams ['boxplot.patchartist' ]
4092+ require_patch = {'edgecolor' , 'facecolor' }
4093+ if require_patch .intersection (boxprops ):
4094+ patch_artist = True
4095+ if patch_artist is True :
40904096 boxprops ['linestyle' ] = 'solid' # Not consistent with bxp.
40914097 if 'color' in boxprops :
40924098 boxprops ['edgecolor' ] = boxprops .pop ('color' )
@@ -4347,7 +4353,7 @@ def merge_kw_rc(subkey, explicit, zdelta=0, usemarker=True):
43474353 else mpl .rcParams ['patch.facecolor' ]),
43484354 'zorder' : zorder ,
43494355 ** cbook .normalize_kwargs (boxprops , mpatches .PathPatch )
4350- } if patch_artist else merge_kw_rc ('box' , boxprops , usemarker = False )
4356+ } if patch_artist is True else merge_kw_rc ('box' , boxprops , usemarker = False )
43514357 whisker_kw = merge_kw_rc ('whisker' , whiskerprops , usemarker = False )
43524358 cap_kw = merge_kw_rc ('cap' , capprops , usemarker = False )
43534359 flier_kw = merge_kw_rc ('flier' , flierprops )
@@ -4462,7 +4468,7 @@ def do_patch(xs, ys, **kwargs):
44624468
44634469 # maybe draw the box
44644470 if showbox :
4465- do_box = do_patch if patch_artist else do_plot
4471+ do_box = do_patch if patch_artist is True else do_plot
44664472 boxes .append (do_box (box_x , box_y , ** box_kw ))
44674473 median_kw .setdefault ('label' , '_nolegend_' )
44684474 # draw the whiskers
0 commit comments