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

Skip to content

Default boxplot style rebase #6481

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

Merged
merged 13 commits into from
May 30, 2016
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
58 changes: 46 additions & 12 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3346,6 +3346,8 @@ def _update_dict(dictionary, rc_name, properties):
# filled symbol, if the users want more control use
# flierprops
flierprops['color'] = color
flierprops['markerfacecolor'] = color
flierprops['markeredgecolor'] = color

# replace medians if necessary:
if usermedians is not None:
Expand Down Expand Up @@ -3558,23 +3560,34 @@ 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']
)
if rcParams['_internal.classic_mode']:
final_boxprops['facecolor'] = 'white'
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 @@ -3584,23 +3597,44 @@ 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'],
)
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
6 changes: 5 additions & 1 deletion lib/matplotlib/mpl-data/stylelib/classic.mplstyle
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ boxplot.meanprops.color: r
boxplot.meanprops.linestyle: -
boxplot.meanprops.linewidth: 1.0
boxplot.medianprops.color: r
boxplot.meanprops.marker: s
boxplot.meanprops.markerfacecolor: r
boxplot.meanprops.markeredgecolor: k
boxplot.meanprops.markersize: 6.0
boxplot.medianprops.linestyle: -
boxplot.medianprops.linewidth: 1.0
boxplot.notch: False
Expand Down Expand Up @@ -503,4 +507,4 @@ animation.convert_path: convert # Path to ImageMagick's convert binary.
animation.convert_args:
animation.html: none

_internal.classic_mode: True
_internal.classic_mode: True
20 changes: 12 additions & 8 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,21 +941,21 @@ 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],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these changes need to be reflected into the template.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can see they already do

'boxplot.flierprops.marker': ['o', six.text_type],
'boxplot.flierprops.markerfacecolor': ['none', validate_color_or_auto],
'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],
Expand All @@ -965,9 +965,13 @@ def validate_animation_writer_path(p):
'boxplot.medianprops.linewidth': [1.0, validate_float],
'boxplot.medianprops.linestyle': ['-', six.text_type],

'boxplot.meanprops.color': ['C3', validate_color],
'boxplot.meanprops.color': ['C2', validate_color],
'boxplot.meanprops.marker': ['^', six.text_type],
'boxplot.meanprops.markerfacecolor': ['C2', validate_color],
'boxplot.meanprops.markeredgecolor': ['C2', validate_color],
'boxplot.meanprops.markersize': [6, validate_float],
'boxplot.meanprops.linestyle': ['--', 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