Skip to content

Commit 12f2624

Browse files
authored
close #16593: setting ecolor turns off color cycling (#16597)
* closes #16593 setting ecolor turns off color cycling Co-authored-by: tacaswell <tcaswell@gmail.com> * added api change * ~.Axes, not ~Axes
1 parent ed79353 commit 12f2624

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

doc/api/next_api_changes/behaviour.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,11 @@ Previously, `.SymLogNorm` had no *base* kwarg, and defaulted to ``base=np.e``
9393
whereas the documentation said it was ``base=10``. In preparation to make
9494
the default 10, calling `.SymLogNorm` without the new *base* kwarg emits a
9595
deprecation warning.
96+
97+
98+
`~.Axes.errorbar` now color cycles when only errorbar color is set
99+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100+
101+
Previously setting the *ecolor* would turn off automatic color cycling for the plot, leading to the
102+
the lines and markers defaulting to whatever the first color in the color cycle was in the case of
103+
multiple plot calls.

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3215,8 +3215,7 @@ def errorbar(self, x, y, yerr=None, xerr=None,
32153215
# Remove alpha=0 color that _process_plot_format returns
32163216
fmt_style_kwargs.pop('color')
32173217

3218-
if ('color' in kwargs or 'color' in fmt_style_kwargs or
3219-
ecolor is not None):
3218+
if ('color' in kwargs or 'color' in fmt_style_kwargs):
32203219
base_style = {}
32213220
if 'color' in kwargs:
32223221
base_style['color'] = kwargs.pop('color')

lib/matplotlib/tests/test_axes.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3157,6 +3157,21 @@ def test_errorbar_colorcycle():
31573157
assert mcolors.to_rgba(ln1.get_color()) == mcolors.to_rgba('C2')
31583158

31593159

3160+
@check_figures_equal()
3161+
def test_errorbar_cycle_ecolor(fig_test, fig_ref):
3162+
x = np.arange(0.1, 4, 0.5)
3163+
y = [np.exp(-x+n) for n in range(4)]
3164+
3165+
axt = fig_test.subplots()
3166+
axr = fig_ref.subplots()
3167+
3168+
for yi, color in zip(y, ['C0', 'C1', 'C2', 'C3']):
3169+
axt.errorbar(x, yi, yerr=(yi * 0.25), linestyle='-',
3170+
marker='o', ecolor='black')
3171+
axr.errorbar(x, yi, yerr=(yi * 0.25), linestyle='-',
3172+
marker='o', color=color, ecolor='black')
3173+
3174+
31603175
def test_errorbar_shape():
31613176
fig = plt.figure()
31623177
ax = fig.gca()

0 commit comments

Comments
 (0)