Skip to content

WIP: updated defult boxplot styles #5523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
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
55 changes: 43 additions & 12 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3516,23 +3516,32 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,

# box properties
if patch_artist:
final_boxprops = dict(linestyle='solid', edgecolor='black',
facecolor='white', linewidth=1)
final_boxprops = dict(
linestyle=rcParams['boxplot.boxprops.linestyle'],
edgecolor=rcParams['boxplot.boxprops.color'],
facecolor=rcParams['patch.facecolor'],
linewidth=rcParams['boxplot.boxprops.linewidth']
)
else:
final_boxprops = dict(linestyle='-', color='blue')
final_boxprops = dict(
linestyle=rcParams['boxplot.boxprops.linestyle'],
color=rcParams['boxplot.boxprops.color'],
)

if boxprops is not None:
final_boxprops.update(boxprops)

# other (cap, whisker) properties
final_whiskerprops = dict(
linestyle='--',
color='blue',
linestyle=rcParams['boxplot.whiskerprops.linestyle'],
linewidth=rcParams['boxplot.whiskerprops.linewidth'],
color=rcParams['boxplot.whiskerprops.color'],
)

final_capprops = dict(
linestyle='-',
color='black',
linestyle=rcParams['boxplot.capprops.linestyle'],
linewidth=rcParams['boxplot.capprops.linewidth'],
color=rcParams['boxplot.capprops.color'],
)

if capprops is not None:
Expand All @@ -3542,23 +3551,45 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
final_whiskerprops.update(whiskerprops)

# set up the default flier properties
final_flierprops = dict(linestyle='none', marker='+', color='blue')
final_flierprops = dict(
linestyle=rcParams['boxplot.flierprops.linestyle'],
linewidth=rcParams['boxplot.flierprops.linewidth'],
color=rcParams['boxplot.flierprops.color'],
marker=rcParams['boxplot.flierprops.marker'],
markerfacecolor=rcParams['boxplot.flierprops.markerfacecolor'],
markeredgecolor=rcParams['boxplot.flierprops.markeredgecolor'],
markersize=rcParams['boxplot.flierprops.markersize'],
)

# flier (outlier) properties
if flierprops is not None:
final_flierprops.update(flierprops)

# median line properties
final_medianprops = dict(linestyle='-', color='red')
final_medianprops = dict(
linestyle=rcParams['boxplot.medianprops.linestyle'],
linewidth=rcParams['boxplot.medianprops.linewidth'],
color=rcParams['boxplot.medianprops.color'],
)
if medianprops is not None:
final_medianprops.update(medianprops)

# mean (line or point) properties
if meanline:
final_meanprops = dict(linestyle='--', color='black')
final_meanprops = dict(
linestyle=rcParams['boxplot.meanprops.linestyle'],
linewidth=rcParams['boxplot.meanprops.linewidth'],
color=rcParams['boxplot.meanprops.color'],
marker='none',
)
else:
final_meanprops = dict(linestyle='none', markerfacecolor='red',
marker='s')
final_meanprops = dict(
linestyle='',
marker=rcParams['boxplot.meanprops.marker'],
markerfacecolor=rcParams['boxplot.meanprops.markerfacecolor'],
markeredgecolor=rcParams['boxplot.meanprops.markeredgecolor'],
markersize=rcParams['boxplot.meanprops.markersize'],
)
if meanprops is not None:
final_meanprops.update(meanprops)

Expand Down
22 changes: 13 additions & 9 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,33 +907,37 @@ def validate_animation_writer_path(p):
'boxplot.showfliers': [True, validate_bool],
'boxplot.meanline': [False, validate_bool],

'boxplot.flierprops.color': ['C0', validate_color],
'boxplot.flierprops.marker': ['+', six.text_type],
'boxplot.flierprops.markerfacecolor': ['auto', validate_color_or_auto],
'boxplot.flierprops.color': ['k', validate_color],
'boxplot.flierprops.marker': ['o', six.text_type],
'boxplot.flierprops.markerfacecolor': ['none', validate_color],
'boxplot.flierprops.markeredgecolor': ['k', validate_color],
'boxplot.flierprops.markersize': [6, validate_float],
'boxplot.flierprops.linestyle': ['none', six.text_type],
'boxplot.flierprops.linewidth': [1.0, validate_float],

'boxplot.boxprops.color': ['C0', validate_color],
'boxplot.boxprops.color': ['k', validate_color],
'boxplot.boxprops.linewidth': [1.0, validate_float],
'boxplot.boxprops.linestyle': ['-', six.text_type],

'boxplot.whiskerprops.color': ['C0', validate_color],
'boxplot.whiskerprops.color': ['k', validate_color],
'boxplot.whiskerprops.linewidth': [1.0, validate_float],
'boxplot.whiskerprops.linestyle': ['--', six.text_type],
'boxplot.whiskerprops.linestyle': ['-', six.text_type],

'boxplot.capprops.color': ['k', validate_color],
'boxplot.capprops.linewidth': [1.0, validate_float],
'boxplot.capprops.linestyle': ['-', six.text_type],

'boxplot.medianprops.color': ['C1', validate_color],
'boxplot.medianprops.color': ['C0', validate_color],
'boxplot.medianprops.linewidth': [1.0, validate_float],
'boxplot.medianprops.linestyle': ['-', six.text_type],

'boxplot.meanprops.color': ['r', validate_color],
'boxplot.meanprops.color': ['C1', six.text_type],
'boxplot.meanprops.marker': ['^', six.text_type],
'boxplot.meanprops.markerfacecolor': ['C1', validate_color],
'boxplot.meanprops.markeredgecolor': ['C1', validate_color],
'boxplot.meanprops.markersize': [6, validate_float],
'boxplot.meanprops.linestyle': ['none', six.text_type],
'boxplot.meanprops.linewidth': [1.0, validate_float],
'boxplot.meanprops.linestyle': ['-', six.text_type],

## font props
'font.family': [['sans-serif'], validate_stringlist], # used by text object
Expand Down
Binary file modified lib/matplotlib/tests/baseline_images/test_axes/boxplot.pdf
Binary file not shown.
Binary file modified lib/matplotlib/tests/baseline_images/test_axes/boxplot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading