diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 152d00b0e4a3..212c405b55fe 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3910,10 +3910,13 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True, zdelta = 0.1 - def line_props_with_rcdefaults(subkey, explicit, zdelta=0): + def line_props_with_rcdefaults(subkey, explicit, zdelta=0, + use_marker=True): d = {k.split('.')[-1]: v for k, v in rcParams.items() if k.startswith(f'boxplot.{subkey}')} d['zorder'] = zorder + zdelta + if not use_marker: + d['marker'] = '' if explicit is not None: d.update( cbook.normalize_kwargs(explicit, mlines.Line2D._alias_map)) @@ -3934,15 +3937,16 @@ def line_props_with_rcdefaults(subkey, explicit, zdelta=0): cbook.normalize_kwargs( boxprops, mpatches.PathPatch._alias_map)) else: - final_boxprops = line_props_with_rcdefaults('boxprops', boxprops) + final_boxprops = line_props_with_rcdefaults('boxprops', boxprops, + use_marker=False) final_whiskerprops = line_props_with_rcdefaults( - 'whiskerprops', whiskerprops) + 'whiskerprops', whiskerprops, use_marker=False) final_capprops = line_props_with_rcdefaults( - 'capprops', capprops) + 'capprops', capprops, use_marker=False) final_flierprops = line_props_with_rcdefaults( 'flierprops', flierprops) final_medianprops = line_props_with_rcdefaults( - 'medianprops', medianprops, zdelta) + 'medianprops', medianprops, zdelta, use_marker=False) final_meanprops = line_props_with_rcdefaults( 'meanprops', meanprops, zdelta) removed_prop = 'marker' if meanline else 'linestyle' diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index c63196056496..b7fbfe412500 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -2701,6 +2701,24 @@ def test_boxplot_bad_ci_2(): ax.boxplot([x, x], conf_intervals=[[1, 2], [1]]) +def test_boxplot_marker_behavior(): + plt.rcParams['lines.marker'] = 's' + plt.rcParams['boxplot.flierprops.marker'] = 'o' + plt.rcParams['boxplot.meanprops.marker'] = '^' + fig, ax = plt.subplots() + test_data = np.arange(100) + test_data[-1] = 150 # a flier point + bxp_handle = ax.boxplot(test_data, showmeans=True) + for bxp_lines in ['whiskers', 'caps', 'boxes', 'medians']: + for each_line in bxp_handle[bxp_lines]: + # Ensure that the rcParams['lines.marker'] is overridden by '' + assert each_line.get_marker() == '' + + # Ensure that markers for fliers and means aren't overridden with '' + assert bxp_handle['fliers'][0].get_marker() == 'o' + assert bxp_handle['means'][0].get_marker() == '^' + + @image_comparison(['boxplot_mod_artists_after_plotting.png'], remove_text=True, savefig_kwarg={'dpi': 40}, style='default') def test_boxplot_mod_artist_after_plotting():