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

Skip to content

Commit 2645afb

Browse files
committed
Merge pull request #3533 from tacaswell/fix_flierprop
BUG : fix handling of flierprop by boxplot
2 parents 20741b5 + 4234f0f commit 2645afb

File tree

2 files changed

+38
-22
lines changed

2 files changed

+38
-22
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2884,7 +2884,7 @@ def xywhere(xs, ys, mask):
28842884

28852885
return errorbar_container # (l0, caplines, barcols)
28862886

2887-
def boxplot(self, x, notch=False, sym='b+', vert=True, whis=1.5,
2887+
def boxplot(self, x, notch=False, sym=None, vert=True, whis=1.5,
28882888
positions=None, widths=None, patch_artist=False,
28892889
bootstrap=None, usermedians=None, conf_intervals=None,
28902890
meanline=False, showmeans=False, showcaps=True,
@@ -2920,9 +2920,11 @@ def boxplot(self, x, notch=False, sym='b+', vert=True, whis=1.5,
29202920
If False, produces a rectangular box plot.
29212921
If True, will produce a notched box plot
29222922
2923-
sym : str, default = 'b+'
2923+
sym : str or None, default = None
29242924
The default symbol for flier points.
29252925
Enter an empty string ('') if you don't want to show fliers.
2926+
If `None`, then the fliers default to 'b+' If you want more
2927+
control use the fliersprop kwarg.
29262928
29272929
vert : bool, default = True
29282930
If True (default), makes the boxes vertical.
@@ -3045,10 +3047,39 @@ def boxplot(self, x, notch=False, sym='b+', vert=True, whis=1.5,
30453047
"""
30463048
bxpstats = cbook.boxplot_stats(x, whis=whis, bootstrap=bootstrap,
30473049
labels=labels)
3050+
# make sure we have a dictionary
30483051
if flierprops is None:
3049-
flierprops = dict(sym=sym)
3050-
else:
3051-
flierprops['sym'] = sym
3052+
flierprops = dict()
3053+
# if non-default sym value, put it into the flier dictionary
3054+
# the logic for providing the default symbol ('b+') now lives
3055+
# in bxp in the initial value of final_flierprops
3056+
# handle all of the `sym` related logic here so we only have to pass
3057+
# on the flierprops dict.
3058+
if sym is not None:
3059+
# no-flier case, which should really be done with
3060+
# 'showfliers=False' but none-the-less deal with it to keep back
3061+
# compatibility
3062+
if sym == '':
3063+
# blow away existing dict and make one for invisible markers
3064+
flierprops = dict(linestyle='none', marker='',
3065+
markeredgecolor='none',
3066+
markerfacecolor='none')
3067+
# now process the symbol string
3068+
else:
3069+
# process the symbol string
3070+
# discarded linestyle
3071+
_, marker, color = _process_plot_format(sym)
3072+
# if we have a marker, use it
3073+
if marker is not None:
3074+
flierprops['marker'] = marker
3075+
# if we have a color, use it
3076+
if color is not None:
3077+
flierprops['color'] = color
3078+
# assume that if color is passed in the user want
3079+
# filled symbol, if the users want more control use
3080+
# flierprops
3081+
flierprops['markeredgecolor'] = color
3082+
flierprops['markerfacecolor'] = color
30523083

30533084
# replace medians if necessary:
30543085
if usermedians is not None:
@@ -3290,24 +3321,9 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
32903321
final_flierprops = dict(linestyle='none', marker='+',
32913322
markeredgecolor='b',
32923323
markerfacecolor='none')
3324+
32933325
# flier (outlier) properties
32943326
if flierprops is not None:
3295-
sym = flierprops.pop('sym', None)
3296-
3297-
# watch inverted logic, checks for non-default
3298-
# value of `sym`
3299-
if not (sym == '' or (sym is None)):
3300-
# process the symbol string
3301-
# discarded linestyle
3302-
_, marker, color = _process_plot_format(sym)
3303-
if marker is not None:
3304-
flierprops['marker'] = marker
3305-
if color is not None:
3306-
flierprops['color'] = color
3307-
# assume that if color is passed in the user want
3308-
# filled symbol
3309-
flierprops['markeredgecolor'] = color
3310-
flierprops['markerfacecolor'] = color
33113327
final_flierprops.update(flierprops)
33123328

33133329
# median line properties

lib/matplotlib/pyplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2616,7 +2616,7 @@ def broken_barh(xranges, yrange, hold=None, **kwargs):
26162616
# This function was autogenerated by boilerplate.py. Do not edit as
26172617
# changes will be lost
26182618
@_autogen_docstring(Axes.boxplot)
2619-
def boxplot(x, notch=False, sym='b+', vert=True, whis=1.5, positions=None,
2619+
def boxplot(x, notch=False, sym=None, vert=True, whis=1.5, positions=None,
26202620
widths=None, patch_artist=False, bootstrap=None, usermedians=None,
26212621
conf_intervals=None, meanline=False, showmeans=False, showcaps=True,
26222622
showbox=True, showfliers=True, boxprops=None, labels=None,

0 commit comments

Comments
 (0)