@@ -3637,33 +3637,23 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
36373637 if showfliers is None :
36383638 showfliers = rcParams ['boxplot.showfliers' ]
36393639
3640- def _update_dict (dictionary , rc_name , properties ):
3641- """ Loads properties in the dictionary from rc file if not already
3642- in the dictionary"""
3643- rc_str = 'boxplot.{0}.{1}'
3644- if dictionary is None :
3645- dictionary = dict ()
3646- for prop_dict in properties :
3647- dictionary .setdefault (prop_dict ,
3648- rcParams [rc_str .format (rc_name , prop_dict )])
3649- return dictionary
3650-
3651- # Common property dicts loading from rc.
3652- flier_props = ['color' , 'marker' , 'markerfacecolor' , 'markeredgecolor' ,
3653- 'markersize' , 'linestyle' , 'linewidth' ]
3654- default_props = ['color' , 'linewidth' , 'linestyle' ]
3655-
3656- boxprops = _update_dict (boxprops , 'boxprops' , default_props )
3657- whiskerprops = _update_dict (whiskerprops , 'whiskerprops' ,
3658- default_props )
3659- capprops = _update_dict (capprops , 'capprops' , default_props )
3660- medianprops = _update_dict (medianprops , 'medianprops' , default_props )
3661- meanprops = _update_dict (meanprops , 'meanprops' , default_props )
3662- flierprops = _update_dict (flierprops , 'flierprops' , flier_props )
3640+ if boxprops is None :
3641+ boxprops = {}
3642+ if whiskerprops is None :
3643+ whiskerprops = {}
3644+ if capprops is None :
3645+ capprops = {}
3646+ if medianprops is None :
3647+ medianprops = {}
3648+ if meanprops is None :
3649+ meanprops = {}
3650+ if flierprops is None :
3651+ flierprops = {}
36633652
36643653 if patch_artist :
3665- boxprops ['linestyle' ] = 'solid'
3666- boxprops ['edgecolor' ] = boxprops .pop ('color' )
3654+ boxprops ['linestyle' ] = 'solid' # Not consistent with bxp.
3655+ if 'color' in boxprops :
3656+ boxprops ['edgecolor' ] = boxprops .pop ('color' )
36673657
36683658 # if non-default sym value, put it into the flier dictionary
36693659 # the logic for providing the default symbol ('b+') now lives
@@ -3898,92 +3888,38 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
38983888 zorder = mlines .Line2D .zorder
38993889
39003890 zdelta = 0.1
3891+
3892+ def with_rcdefaults (subkey , explicit , zdelta = 0 ):
3893+ d = {k .split ('.' )[- 1 ]: v for k , v in rcParams .items ()
3894+ if k .startswith (f'boxplot.{ subkey } ' )}
3895+ d ['zorder' ] = zorder + zdelta
3896+ if explicit is not None :
3897+ d .update (explicit )
3898+ return d
3899+
39013900 # box properties
39023901 if patch_artist :
39033902 final_boxprops = dict (
39043903 linestyle = rcParams ['boxplot.boxprops.linestyle' ],
3904+ linewidth = rcParams ['boxplot.boxprops.linewidth' ],
39053905 edgecolor = rcParams ['boxplot.boxprops.color' ],
3906- facecolor = rcParams ['patch.facecolor' ],
3907- linewidth = rcParams ['boxplot.boxprops.linewidth' ]
3906+ facecolor = ('white' if rcParams ['_internal.classic_mode' ] else
3907+ rcParams ['patch.facecolor' ]),
3908+ zorder = zorder ,
39083909 )
3909- if rcParams [ '_internal.classic_mode' ] :
3910- final_boxprops [ 'facecolor' ] = 'white'
3910+ if boxprops is not None :
3911+ final_boxprops . update ( boxprops )
39113912 else :
3912- final_boxprops = dict (
3913- linestyle = rcParams ['boxplot.boxprops.linestyle' ],
3914- color = rcParams ['boxplot.boxprops.color' ],
3915- )
3916-
3917- final_boxprops ['zorder' ] = zorder
3918- if boxprops is not None :
3919- final_boxprops .update (boxprops )
3920-
3921- # other (cap, whisker) properties
3922- final_whiskerprops = dict (
3923- linestyle = rcParams ['boxplot.whiskerprops.linestyle' ],
3924- linewidth = rcParams ['boxplot.whiskerprops.linewidth' ],
3925- color = rcParams ['boxplot.whiskerprops.color' ],
3926- )
3927-
3928- final_capprops = dict (
3929- linestyle = rcParams ['boxplot.capprops.linestyle' ],
3930- linewidth = rcParams ['boxplot.capprops.linewidth' ],
3931- color = rcParams ['boxplot.capprops.color' ],
3932- )
3933-
3934- final_capprops ['zorder' ] = zorder
3935- if capprops is not None :
3936- final_capprops .update (capprops )
3937-
3938- final_whiskerprops ['zorder' ] = zorder
3939- if whiskerprops is not None :
3940- final_whiskerprops .update (whiskerprops )
3941-
3942- # set up the default flier properties
3943- final_flierprops = dict (
3944- linestyle = rcParams ['boxplot.flierprops.linestyle' ],
3945- linewidth = rcParams ['boxplot.flierprops.linewidth' ],
3946- color = rcParams ['boxplot.flierprops.color' ],
3947- marker = rcParams ['boxplot.flierprops.marker' ],
3948- markerfacecolor = rcParams ['boxplot.flierprops.markerfacecolor' ],
3949- markeredgecolor = rcParams ['boxplot.flierprops.markeredgecolor' ],
3950- markeredgewidth = rcParams ['boxplot.flierprops.markeredgewidth' ],
3951- markersize = rcParams ['boxplot.flierprops.markersize' ],
3952- )
3953-
3954- final_flierprops ['zorder' ] = zorder
3955- # flier (outlier) properties
3956- if flierprops is not None :
3957- final_flierprops .update (flierprops )
3958-
3959- # median line properties
3960- final_medianprops = dict (
3961- linestyle = rcParams ['boxplot.medianprops.linestyle' ],
3962- linewidth = rcParams ['boxplot.medianprops.linewidth' ],
3963- color = rcParams ['boxplot.medianprops.color' ],
3964- )
3965- final_medianprops ['zorder' ] = zorder + zdelta
3966- if medianprops is not None :
3967- final_medianprops .update (medianprops )
3968-
3969- # mean (line or point) properties
3970- if meanline :
3971- final_meanprops = dict (
3972- linestyle = rcParams ['boxplot.meanprops.linestyle' ],
3973- linewidth = rcParams ['boxplot.meanprops.linewidth' ],
3974- color = rcParams ['boxplot.meanprops.color' ],
3975- )
3976- else :
3977- final_meanprops = dict (
3978- linestyle = '' ,
3979- marker = rcParams ['boxplot.meanprops.marker' ],
3980- markerfacecolor = rcParams ['boxplot.meanprops.markerfacecolor' ],
3981- markeredgecolor = rcParams ['boxplot.meanprops.markeredgecolor' ],
3982- markersize = rcParams ['boxplot.meanprops.markersize' ],
3983- )
3984- final_meanprops ['zorder' ] = zorder + zdelta
3985- if meanprops is not None :
3986- final_meanprops .update (meanprops )
3913+ final_boxprops = with_rcdefaults ('boxprops' , boxprops )
3914+ final_whiskerprops = with_rcdefaults ('whiskerprops' , whiskerprops )
3915+ final_capprops = with_rcdefaults ('capprops' , capprops )
3916+ final_flierprops = with_rcdefaults ('flierprops' , flierprops )
3917+ final_medianprops = with_rcdefaults ('medianprops' , medianprops , zdelta )
3918+ final_meanprops = with_rcdefaults ('meanprops' , meanprops , zdelta )
3919+ removed_prop = 'marker' if meanline else 'linestyle'
3920+ # Only remove the property if it's not set explicitly as a parameter.
3921+ if meanprops is None or removed_prop not in meanprops :
3922+ final_meanprops [removed_prop ] = ''
39873923
39883924 def to_vc (xs , ys ):
39893925 # convert arguments to verts and codes, append (0, 0) (ignored).
0 commit comments