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

Skip to content

Commit 389a7ed

Browse files
authored
Merge pull request #7276 from phobson/bxp-optional-fliers
FIX: don't compute flier positions if not showing
2 parents 7d0be18 + efe5f4b commit 389a7ed

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3733,9 +3733,6 @@ def dopatch(xs, ys, **kwargs):
37333733
for pos, width, stats in zip(positions, widths, bxpstats):
37343734
# try to find a new label
37353735
datalabels.append(stats.get('label', pos))
3736-
# fliers coords
3737-
flier_x = np.ones(len(stats['fliers'])) * pos
3738-
flier_y = stats['fliers']
37393736

37403737
# whisker coords
37413738
whisker_x = np.ones(2) * pos
@@ -3809,6 +3806,10 @@ def dopatch(xs, ys, **kwargs):
38093806

38103807
# maybe draw the fliers
38113808
if showfliers:
3809+
# fliers coords
3810+
flier_x = np.ones(len(stats['fliers'])) * pos
3811+
flier_y = stats['fliers']
3812+
38123813
fliers.extend(doplot(
38133814
flier_x, flier_y, **final_flierprops
38143815
))

lib/matplotlib/tests/test_axes.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,23 @@ def test_bxp_nobox():
17121712
ax.bxp(logstats, showbox=False)
17131713

17141714

1715+
@image_comparison(baseline_images=['bxp_no_flier_stats'],
1716+
remove_text=True, extensions=['png'],
1717+
savefig_kwarg={'dpi': 40},
1718+
style='default')
1719+
def test_bxp_no_flier_stats():
1720+
np.random.seed(937)
1721+
logstats = matplotlib.cbook.boxplot_stats(
1722+
np.random.lognormal(mean=1.25, sigma=1., size=(37, 4))
1723+
)
1724+
for ls in logstats:
1725+
ls.pop('fliers', None)
1726+
1727+
fig, ax = plt.subplots()
1728+
ax.set_yscale('log')
1729+
ax.bxp(logstats, showfliers=False)
1730+
1731+
17151732
@image_comparison(baseline_images=['bxp_withmean_point'],
17161733
remove_text=True, extensions=['png'],
17171734
savefig_kwarg={'dpi': 40},

0 commit comments

Comments
 (0)