@@ -3821,7 +3821,7 @@ def apply_mask(arrays, mask):
3821
3821
@_api .rename_parameter ("3.9" , "labels" , "tick_labels" )
3822
3822
def boxplot (self , x , notch = None , sym = None , vert = None ,
3823
3823
orientation = 'vertical' , whis = None , positions = None ,
3824
- widths = None , patch_artist = None , bootstrap = None ,
3824
+ widths = None , patch_artist = 'auto' , bootstrap = None ,
3825
3825
usermedians = None , conf_intervals = None ,
3826
3826
meanline = None , showmeans = None , showcaps = None ,
3827
3827
showbox = None , showfliers = None , boxprops = None ,
@@ -3947,9 +3947,12 @@ def boxplot(self, x, notch=None, sym=None, vert=None,
3947
3947
The widths of the boxes. The default is 0.5, or ``0.15*(distance
3948
3948
between extreme positions)``, if that is smaller.
3949
3949
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.
3953
3956
3954
3957
tick_labels : list of str, optional
3955
3958
The tick labels of each boxplot.
@@ -4060,8 +4063,6 @@ def boxplot(self, x, notch=None, sym=None, vert=None,
4060
4063
labels = tick_labels , autorange = autorange )
4061
4064
if notch is None :
4062
4065
notch = mpl .rcParams ['boxplot.notch' ]
4063
- if patch_artist is None :
4064
- patch_artist = mpl .rcParams ['boxplot.patchartist' ]
4065
4066
if meanline is None :
4066
4067
meanline = mpl .rcParams ['boxplot.meanline' ]
4067
4068
if showmeans is None :
@@ -4086,7 +4087,12 @@ def boxplot(self, x, notch=None, sym=None, vert=None,
4086
4087
if flierprops is None :
4087
4088
flierprops = {}
4088
4089
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 :
4090
4096
boxprops ['linestyle' ] = 'solid' # Not consistent with bxp.
4091
4097
if 'color' in boxprops :
4092
4098
boxprops ['edgecolor' ] = boxprops .pop ('color' )
@@ -4347,7 +4353,7 @@ def merge_kw_rc(subkey, explicit, zdelta=0, usemarker=True):
4347
4353
else mpl .rcParams ['patch.facecolor' ]),
4348
4354
'zorder' : zorder ,
4349
4355
** 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 )
4351
4357
whisker_kw = merge_kw_rc ('whisker' , whiskerprops , usemarker = False )
4352
4358
cap_kw = merge_kw_rc ('cap' , capprops , usemarker = False )
4353
4359
flier_kw = merge_kw_rc ('flier' , flierprops )
@@ -4462,7 +4468,7 @@ def do_patch(xs, ys, **kwargs):
4462
4468
4463
4469
# maybe draw the box
4464
4470
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
4466
4472
boxes .append (do_box (box_x , box_y , ** box_kw ))
4467
4473
median_kw .setdefault ('label' , '_nolegend_' )
4468
4474
# draw the whiskers
0 commit comments