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

Skip to content

Commit 13efff3

Browse files
authored
Merge pull request #14253 from meeseeksmachine/auto-backport-of-pr-13596-on-v3.1.x
Backport PR #13596 on branch v3.1.x (Normalize properties passed to bxp().)
2 parents 6ff5082 + ed6b056 commit 13efff3

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
@@ -3937,12 +3937,13 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
39373937

39383938
zdelta = 0.1
39393939

3940-
def with_rcdefaults(subkey, explicit, zdelta=0):
3940+
def line_props_with_rcdefaults(subkey, explicit, zdelta=0):
39413941
d = {k.split('.')[-1]: v for k, v in rcParams.items()
39423942
if k.startswith(f'boxplot.{subkey}')}
39433943
d['zorder'] = zorder + zdelta
39443944
if explicit is not None:
3945-
d.update(explicit)
3945+
d.update(
3946+
cbook.normalize_kwargs(explicit, mlines.Line2D._alias_map))
39463947
return d
39473948

39483949
# box properties
@@ -3956,14 +3957,21 @@ def with_rcdefaults(subkey, explicit, zdelta=0):
39563957
zorder=zorder,
39573958
)
39583959
if boxprops is not None:
3959-
final_boxprops.update(boxprops)
3960+
final_boxprops.update(
3961+
cbook.normalize_kwargs(
3962+
boxprops, mpatches.PathPatch._alias_map))
39603963
else:
3961-
final_boxprops = with_rcdefaults('boxprops', boxprops)
3962-
final_whiskerprops = with_rcdefaults('whiskerprops', whiskerprops)
3963-
final_capprops = with_rcdefaults('capprops', capprops)
3964-
final_flierprops = with_rcdefaults('flierprops', flierprops)
3965-
final_medianprops = with_rcdefaults('medianprops', medianprops, zdelta)
3966-
final_meanprops = with_rcdefaults('meanprops', meanprops, zdelta)
3964+
final_boxprops = line_props_with_rcdefaults('boxprops', boxprops)
3965+
final_whiskerprops = line_props_with_rcdefaults(
3966+
'whiskerprops', whiskerprops)
3967+
final_capprops = line_props_with_rcdefaults(
3968+
'capprops', capprops)
3969+
final_flierprops = line_props_with_rcdefaults(
3970+
'flierprops', flierprops)
3971+
final_medianprops = line_props_with_rcdefaults(
3972+
'medianprops', medianprops, zdelta)
3973+
final_meanprops = line_props_with_rcdefaults(
3974+
'meanprops', meanprops, zdelta)
39673975
removed_prop = 'marker' if meanline else 'linestyle'
39683976
# Only remove the property if it's not set explicitly as a parameter.
39693977
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
@@ -2241,7 +2241,7 @@ def test_bxp_patchartist():
22412241
def test_bxp_custompatchartist():
22422242
_bxp_test_helper(bxp_kwargs=dict(
22432243
patch_artist=True,
2244-
boxprops=dict(facecolor='yellow', edgecolor='green', linestyle=':')))
2244+
boxprops=dict(facecolor='yellow', edgecolor='green', ls=':')))
22452245

22462246

22472247
@image_comparison(baseline_images=['bxp_customoutlier'],
@@ -2250,7 +2250,7 @@ def test_bxp_custompatchartist():
22502250
style='default')
22512251
def test_bxp_customoutlier():
22522252
_bxp_test_helper(bxp_kwargs=dict(
2253-
flierprops=dict(linestyle='none', marker='d', markerfacecolor='g')))
2253+
flierprops=dict(linestyle='none', marker='d', mfc='g')))
22542254

22552255

22562256
@image_comparison(baseline_images=['bxp_withmean_custompoint'],
@@ -2260,7 +2260,7 @@ def test_bxp_customoutlier():
22602260
def test_bxp_showcustommean():
22612261
_bxp_test_helper(bxp_kwargs=dict(
22622262
showmeans=True,
2263-
meanprops=dict(linestyle='none', marker='d', markerfacecolor='green'),
2263+
meanprops=dict(linestyle='none', marker='d', mfc='green'),
22642264
))
22652265

22662266

@@ -2270,7 +2270,7 @@ def test_bxp_showcustommean():
22702270
style='default')
22712271
def test_bxp_custombox():
22722272
_bxp_test_helper(bxp_kwargs=dict(
2273-
boxprops=dict(linestyle='--', color='b', linewidth=3)))
2273+
boxprops=dict(linestyle='--', color='b', lw=3)))
22742274

22752275

22762276
@image_comparison(baseline_images=['bxp_custommedian'],
@@ -2279,7 +2279,7 @@ def test_bxp_custombox():
22792279
style='default')
22802280
def test_bxp_custommedian():
22812281
_bxp_test_helper(bxp_kwargs=dict(
2282-
medianprops=dict(linestyle='--', color='b', linewidth=3)))
2282+
medianprops=dict(linestyle='--', color='b', lw=3)))
22832283

22842284

22852285
@image_comparison(baseline_images=['bxp_customcap'],
@@ -2288,7 +2288,7 @@ def test_bxp_custommedian():
22882288
style='default')
22892289
def test_bxp_customcap():
22902290
_bxp_test_helper(bxp_kwargs=dict(
2291-
capprops=dict(linestyle='--', color='g', linewidth=3)))
2291+
capprops=dict(linestyle='--', color='g', lw=3)))
22922292

22932293

22942294
@image_comparison(baseline_images=['bxp_customwhisker'],
@@ -2297,7 +2297,7 @@ def test_bxp_customcap():
22972297
style='default')
22982298
def test_bxp_customwhisker():
22992299
_bxp_test_helper(bxp_kwargs=dict(
2300-
whiskerprops=dict(linestyle='-', color='m', linewidth=3)))
2300+
whiskerprops=dict(linestyle='-', color='m', lw=3)))
23012301

23022302

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

0 commit comments

Comments
 (0)