Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3937,12 +3937,13 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,

zdelta = 0.1

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

# box properties
Expand All @@ -3956,14 +3957,21 @@ def with_rcdefaults(subkey, explicit, zdelta=0):
zorder=zorder,
)
if boxprops is not None:
final_boxprops.update(boxprops)
final_boxprops.update(
cbook.normalize_kwargs(
boxprops, mpatches.PathPatch._alias_map))
else:
final_boxprops = with_rcdefaults('boxprops', boxprops)
final_whiskerprops = with_rcdefaults('whiskerprops', whiskerprops)
final_capprops = with_rcdefaults('capprops', capprops)
final_flierprops = with_rcdefaults('flierprops', flierprops)
final_medianprops = with_rcdefaults('medianprops', medianprops, zdelta)
final_meanprops = with_rcdefaults('meanprops', meanprops, zdelta)
final_boxprops = line_props_with_rcdefaults('boxprops', boxprops)
final_whiskerprops = line_props_with_rcdefaults(
'whiskerprops', whiskerprops)
final_capprops = line_props_with_rcdefaults(
'capprops', capprops)
final_flierprops = line_props_with_rcdefaults(
'flierprops', flierprops)
final_medianprops = line_props_with_rcdefaults(
'medianprops', medianprops, zdelta)
final_meanprops = line_props_with_rcdefaults(
'meanprops', meanprops, zdelta)
removed_prop = 'marker' if meanline else 'linestyle'
# Only remove the property if it's not set explicitly as a parameter.
if meanprops is None or removed_prop not in meanprops:
Expand Down
14 changes: 7 additions & 7 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2241,7 +2241,7 @@ def test_bxp_patchartist():
def test_bxp_custompatchartist():
_bxp_test_helper(bxp_kwargs=dict(
patch_artist=True,
boxprops=dict(facecolor='yellow', edgecolor='green', linestyle=':')))
boxprops=dict(facecolor='yellow', edgecolor='green', ls=':')))


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


@image_comparison(baseline_images=['bxp_withmean_custompoint'],
Expand All @@ -2260,7 +2260,7 @@ def test_bxp_customoutlier():
def test_bxp_showcustommean():
_bxp_test_helper(bxp_kwargs=dict(
showmeans=True,
meanprops=dict(linestyle='none', marker='d', markerfacecolor='green'),
meanprops=dict(linestyle='none', marker='d', mfc='green'),
))


Expand All @@ -2270,7 +2270,7 @@ def test_bxp_showcustommean():
style='default')
def test_bxp_custombox():
_bxp_test_helper(bxp_kwargs=dict(
boxprops=dict(linestyle='--', color='b', linewidth=3)))
boxprops=dict(linestyle='--', color='b', lw=3)))


@image_comparison(baseline_images=['bxp_custommedian'],
Expand All @@ -2279,7 +2279,7 @@ def test_bxp_custombox():
style='default')
def test_bxp_custommedian():
_bxp_test_helper(bxp_kwargs=dict(
medianprops=dict(linestyle='--', color='b', linewidth=3)))
medianprops=dict(linestyle='--', color='b', lw=3)))


@image_comparison(baseline_images=['bxp_customcap'],
Expand All @@ -2288,7 +2288,7 @@ def test_bxp_custommedian():
style='default')
def test_bxp_customcap():
_bxp_test_helper(bxp_kwargs=dict(
capprops=dict(linestyle='--', color='g', linewidth=3)))
capprops=dict(linestyle='--', color='g', lw=3)))


@image_comparison(baseline_images=['bxp_customwhisker'],
Expand All @@ -2297,7 +2297,7 @@ def test_bxp_customcap():
style='default')
def test_bxp_customwhisker():
_bxp_test_helper(bxp_kwargs=dict(
whiskerprops=dict(linestyle='-', color='m', linewidth=3)))
whiskerprops=dict(linestyle='-', color='m', lw=3)))


@image_comparison(baseline_images=['bxp_withnotch'],
Expand Down