Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dc16c70

Browse files
committed
closes #16593 setting ecolor turns off color cycling
Co-authored-by: tacaswell <[email protected]> flake errors
1 parent 3b04c7d commit dc16c70

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 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')
@@ -3227,6 +3226,7 @@ def errorbar(self, x, y, yerr=None, xerr=None,
32273226
base_style.update(fmt_style_kwargs)
32283227
if 'color' not in base_style:
32293228
base_style['color'] = 'C0'
3229+
color = 'C0'
32303230
if ecolor is None:
32313231
ecolor = base_style['color']
32323232
# make sure all the args are iterable; use lists not arrays to

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+
axt = fig_test.subplots()
3165+
for yi in y:
3166+
axt.errorbar(x, yi, yerr=(yi * 0.25), linestyle='-',
3167+
marker='o', ecolor='black')
3168+
3169+
axr = fig_ref.subplots()
3170+
for yi, color in zip(y, ['C0', 'C1', 'C2', 'C3']):
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)