diff --git a/doc/api/next_api_changes/behaviour.rst b/doc/api/next_api_changes/behaviour.rst index 3cca24e94df7..d7bce770b3f4 100644 --- a/doc/api/next_api_changes/behaviour.rst +++ b/doc/api/next_api_changes/behaviour.rst @@ -93,3 +93,11 @@ Previously, `.SymLogNorm` had no *base* kwarg, and defaulted to ``base=np.e`` whereas the documentation said it was ``base=10``. In preparation to make the default 10, calling `.SymLogNorm` without the new *base* kwarg emits a deprecation warning. + + +`~.Axes.errorbar` now color cycles when only errorbar color is set +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Previously setting the *ecolor* would turn off automatic color cycling for the plot, leading to the +the lines and markers defaulting to whatever the first color in the color cycle was in the case of +multiple plot calls. \ No newline at end of file diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 72a9c782e6a4..01ad682c013a 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3215,8 +3215,7 @@ def errorbar(self, x, y, yerr=None, xerr=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): + if ('color' in kwargs or 'color' in fmt_style_kwargs): base_style = {} if 'color' in kwargs: base_style['color'] = kwargs.pop('color') diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 9be1a6252181..47a028256640 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -3157,6 +3157,21 @@ def test_errorbar_colorcycle(): assert mcolors.to_rgba(ln1.get_color()) == mcolors.to_rgba('C2') +@check_figures_equal() +def test_errorbar_cycle_ecolor(fig_test, fig_ref): + x = np.arange(0.1, 4, 0.5) + y = [np.exp(-x+n) for n in range(4)] + + axt = fig_test.subplots() + axr = fig_ref.subplots() + + for yi, color in zip(y, ['C0', 'C1', 'C2', 'C3']): + axt.errorbar(x, yi, yerr=(yi * 0.25), linestyle='-', + marker='o', ecolor='black') + axr.errorbar(x, yi, yerr=(yi * 0.25), linestyle='-', + marker='o', color=color, ecolor='black') + + def test_errorbar_shape(): fig = plt.figure() ax = fig.gca()