Skip to content

Commit 462362f

Browse files
committed
BUG : fix errors when using fliers
doplot for horizontal boxes (internal bxp helper function) assumes that it will be passed an even number of positional arguments which it swaps pair-wise. The code to draw the fliers also passes in a format string which breaks the assumption. - re-worked how `bxp` deals with the `sym` input - minor pep8
1 parent 4b81a4f commit 462362f

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import matplotlib.transforms as mtrans
4040
from matplotlib.container import BarContainer, ErrorbarContainer, StemContainer
4141
from matplotlib.axes._base import _AxesBase
42+
from matplotlib.axes._base import _process_plot_format
4243

4344
iterable = cbook.iterable
4445
is_string_like = cbook.is_string_like
@@ -3254,21 +3255,23 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
32543255
if whiskerprops is not None:
32553256
final_whiskerprops.update(whiskerprops)
32563257

3258+
# set up the default flier properties
3259+
final_flierprops = dict(linestyle='none', marker='+',
3260+
markeredgecolor='b',
3261+
markerfacecolor='none')
32573262
# flier (outlier) properties
32583263
if flierprops is not None:
3259-
sym = flierprops.pop('sym', '')
3260-
3261-
if sym == '':
3262-
final_flierprops = dict(linestyle='none', marker='+',
3263-
markeredgecolor='b',
3264-
markerfacecolor='none')
3265-
else:
3266-
final_flierprops = dict(linestyle='none')
3264+
sym = flierprops.pop('sym', None)
3265+
3266+
# watch inverted logic, checks for non-default
3267+
# value of `sym`
3268+
if not (sym == '' or (sym is None)):
3269+
# process the symbol string
3270+
# discarded linestyle
3271+
_, marker, color = _process_plot_format(sym)
3272+
final_flierprops['marker'] = marker
3273+
final_flierprops['color'] = color
32673274
final_flierprops.update(flierprops)
3268-
else:
3269-
sym = ''
3270-
final_flierprops = dict(linestyle='none', marker='+',
3271-
markeredgecolor='b')
32723275

32733276
# median line properties
32743277
final_medianprops = dict(linestyle='-', color='red')
@@ -3398,10 +3401,10 @@ def dopatch(xs, ys, **kwargs):
33983401

33993402
# draw the whiskers
34003403
whiskers.extend(doplot(
3401-
whisker_x, whiskerlo_y,**final_whiskerprops
3404+
whisker_x, whiskerlo_y, **final_whiskerprops
34023405
))
34033406
whiskers.extend(doplot(
3404-
whisker_x, whiskerhi_y,**final_whiskerprops
3407+
whisker_x, whiskerhi_y, **final_whiskerprops
34053408
))
34063409

34073410
# maybe draw the caps:
@@ -3427,7 +3430,7 @@ def dopatch(xs, ys, **kwargs):
34273430
# maybe draw the fliers
34283431
if showfliers:
34293432
fliers.extend(doplot(
3430-
flier_x, flier_y, sym, **final_flierprops
3433+
flier_x, flier_y, **final_flierprops
34313434
))
34323435

34333436
# fix our axes/ticks up a little

0 commit comments

Comments
 (0)