Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit efe5f4b

Browse filesBrowse files
committed
FIX: don't compute flier positions if not showing
Closes GH #7263 Fliers are documented as being optional when showfliers=False. However the Axes.bxp method was trying to compute the x-values of the flier artists based on the length of the flier array before the logic to draw them.
1 parent 7d0be18 commit efe5f4b
Copy full SHA for efe5f4b

File tree

Expand file treeCollapse file tree

3 files changed

+21
-3
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+21
-3
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+4-3Lines 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
))
Loading

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+17Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.