diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index d25a91bdc2a0..d2c50c1b5e78 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -2820,6 +2820,9 @@ def errorbar(self, x, y, yerr=None, xerr=None, fmt_style_kwargs = {k: v for k, v in zip(('linestyle', 'marker', 'color'), _process_plot_format(fmt)) if v is not None} + if fmt == 'none': + # Remove alpha=0 color that _process_plot_format returns + fmt_style_kwargs.pop('color') if ('color' in kwargs or 'color' in fmt_style_kwargs or ecolor is not None): diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 223625d7610c..cd6bdf7b2139 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -2454,6 +2454,18 @@ def test_errorbar_limits(): ax.set_title('Errorbar upper and lower limits') +@cleanup +def test_errobar_nonefmt(): + # Check that passing 'none' as a format still plots errorbars + x = np.arange(5) + y = np.arange(5) + + plotline, _, barlines = plt.errorbar(x, y, xerr=1, yerr=1, fmt='none') + assert plotline is None + for errbar in barlines: + assert np.all(errbar.get_color() == mcolors.to_rgba('C0')) + + @image_comparison(baseline_images=['hist_stacked_stepfilled', 'hist_stacked_stepfilled']) def test_hist_stacked_stepfilled():