diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index bbd3519bf581..f042ee2be7cf 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3733,9 +3733,6 @@ def dopatch(xs, ys, **kwargs): for pos, width, stats in zip(positions, widths, bxpstats): # try to find a new label datalabels.append(stats.get('label', pos)) - # fliers coords - flier_x = np.ones(len(stats['fliers'])) * pos - flier_y = stats['fliers'] # whisker coords whisker_x = np.ones(2) * pos @@ -3809,6 +3806,10 @@ def dopatch(xs, ys, **kwargs): # maybe draw the fliers if showfliers: + # fliers coords + flier_x = np.ones(len(stats['fliers'])) * pos + flier_y = stats['fliers'] + fliers.extend(doplot( flier_x, flier_y, **final_flierprops )) diff --git a/lib/matplotlib/tests/baseline_images/test_axes/bxp_no_flier_stats.png b/lib/matplotlib/tests/baseline_images/test_axes/bxp_no_flier_stats.png new file mode 100644 index 000000000000..4df5cd0905d5 Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_axes/bxp_no_flier_stats.png differ diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 8fee7bcd0c5f..f1624d53ff1b 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -1712,6 +1712,23 @@ def test_bxp_nobox(): ax.bxp(logstats, showbox=False) +@image_comparison(baseline_images=['bxp_no_flier_stats'], + remove_text=True, extensions=['png'], + savefig_kwarg={'dpi': 40}, + style='default') +def test_bxp_no_flier_stats(): + np.random.seed(937) + logstats = matplotlib.cbook.boxplot_stats( + np.random.lognormal(mean=1.25, sigma=1., size=(37, 4)) + ) + for ls in logstats: + ls.pop('fliers', None) + + fig, ax = plt.subplots() + ax.set_yscale('log') + ax.bxp(logstats, showfliers=False) + + @image_comparison(baseline_images=['bxp_withmean_point'], remove_text=True, extensions=['png'], savefig_kwarg={'dpi': 40},