Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef1567f

Browse files
committed
Normalize properties passed to bxp().
1 parent 1a89250 commit ef1567f

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3899,12 +3899,13 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
38993899

39003900
zdelta = 0.1
39013901

3902-
def with_rcdefaults(subkey, explicit, zdelta=0):
3902+
def line_props_with_rcdefaults(subkey, explicit, zdelta=0):
39033903
d = {k.split('.')[-1]: v for k, v in rcParams.items()
39043904
if k.startswith(f'boxplot.{subkey}')}
39053905
d['zorder'] = zorder + zdelta
39063906
if explicit is not None:
3907-
d.update(explicit)
3907+
d.update(
3908+
cbook.normalize_kwargs(explicit, mlines.Line2D._alias_map))
39083909
return d
39093910

39103911
# box properties
@@ -3918,14 +3919,21 @@ def with_rcdefaults(subkey, explicit, zdelta=0):
39183919
zorder=zorder,
39193920
)
39203921
if boxprops is not None:
3921-
final_boxprops.update(boxprops)
3922+
final_boxprops.update(
3923+
cbook.normalize_kwargs(
3924+
boxprops, mpatches.PathPatch._alias_map))
39223925
else:
3923-
final_boxprops = with_rcdefaults('boxprops', boxprops)
3924-
final_whiskerprops = with_rcdefaults('whiskerprops', whiskerprops)
3925-
final_capprops = with_rcdefaults('capprops', capprops)
3926-
final_flierprops = with_rcdefaults('flierprops', flierprops)
3927-
final_medianprops = with_rcdefaults('medianprops', medianprops, zdelta)
3928-
final_meanprops = with_rcdefaults('meanprops', meanprops, zdelta)
3926+
final_boxprops = line_props_with_rcdefaults('boxprops', boxprops)
3927+
final_whiskerprops = line_props_with_rcdefaults(
3928+
'whiskerprops', whiskerprops)
3929+
final_capprops = line_props_with_rcdefaults(
3930+
'capprops', capprops)
3931+
final_flierprops = line_props_with_rcdefaults(
3932+
'flierprops', flierprops)
3933+
final_medianprops = line_props_with_rcdefaults(
3934+
'medianprops', medianprops, zdelta)
3935+
final_meanprops = line_props_with_rcdefaults(
3936+
'meanprops', meanprops, zdelta)
39293937
removed_prop = 'marker' if meanline else 'linestyle'
39303938
# Only remove the property if it's not set explicitly as a parameter.
39313939
if meanprops is None or removed_prop not in meanprops:

lib/matplotlib/tests/test_axes.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2236,7 +2236,7 @@ def test_bxp_patchartist():
22362236
def test_bxp_custompatchartist():
22372237
_bxp_test_helper(bxp_kwargs=dict(
22382238
patch_artist=True,
2239-
boxprops=dict(facecolor='yellow', edgecolor='green', linestyle=':')))
2239+
boxprops=dict(facecolor='yellow', edgecolor='green', ls=':')))
22402240

22412241

22422242
@image_comparison(baseline_images=['bxp_customoutlier'],
@@ -2245,7 +2245,7 @@ def test_bxp_custompatchartist():
22452245
style='default')
22462246
def test_bxp_customoutlier():
22472247
_bxp_test_helper(bxp_kwargs=dict(
2248-
flierprops=dict(linestyle='none', marker='d', markerfacecolor='g')))
2248+
flierprops=dict(linestyle='none', marker='d', mfc='g')))
22492249

22502250

22512251
@image_comparison(baseline_images=['bxp_withmean_custompoint'],
@@ -2255,7 +2255,7 @@ def test_bxp_customoutlier():
22552255
def test_bxp_showcustommean():
22562256
_bxp_test_helper(bxp_kwargs=dict(
22572257
showmeans=True,
2258-
meanprops=dict(linestyle='none', marker='d', markerfacecolor='green'),
2258+
meanprops=dict(linestyle='none', marker='d', mfc='green'),
22592259
))
22602260

22612261

@@ -2265,7 +2265,7 @@ def test_bxp_showcustommean():
22652265
style='default')
22662266
def test_bxp_custombox():
22672267
_bxp_test_helper(bxp_kwargs=dict(
2268-
boxprops=dict(linestyle='--', color='b', linewidth=3)))
2268+
boxprops=dict(linestyle='--', color='b', lw=3)))
22692269

22702270

22712271
@image_comparison(baseline_images=['bxp_custommedian'],
@@ -2274,7 +2274,7 @@ def test_bxp_custombox():
22742274
style='default')
22752275
def test_bxp_custommedian():
22762276
_bxp_test_helper(bxp_kwargs=dict(
2277-
medianprops=dict(linestyle='--', color='b', linewidth=3)))
2277+
medianprops=dict(linestyle='--', color='b', lw=3)))
22782278

22792279

22802280
@image_comparison(baseline_images=['bxp_customcap'],
@@ -2283,7 +2283,7 @@ def test_bxp_custommedian():
22832283
style='default')
22842284
def test_bxp_customcap():
22852285
_bxp_test_helper(bxp_kwargs=dict(
2286-
capprops=dict(linestyle='--', color='g', linewidth=3)))
2286+
capprops=dict(linestyle='--', color='g', lw=3)))
22872287

22882288

22892289
@image_comparison(baseline_images=['bxp_customwhisker'],
@@ -2292,7 +2292,7 @@ def test_bxp_customcap():
22922292
style='default')
22932293
def test_bxp_customwhisker():
22942294
_bxp_test_helper(bxp_kwargs=dict(
2295-
whiskerprops=dict(linestyle='-', color='m', linewidth=3)))
2295+
whiskerprops=dict(linestyle='-', color='m', lw=3)))
22962296

22972297

22982298
@image_comparison(baseline_images=['bxp_withnotch'],

0 commit comments

Comments
 (0)