Skip to content

Commit 56be9e1

Browse files
committed
closes #16593 setting ecolor turns off color cycling
Co-authored-by: tacaswell <tcaswell@gmail.com>
1 parent 9a24fb7 commit 56be9e1

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3266,7 +3266,21 @@ def test_errorbar_offsets(fig_test, fig_ref):
32663266
ax_ref.errorbar(x[shift::4], y[shift::4], yerr[shift::4],
32673267
capsize=4, c=color, fmt='none')
32683268

3269-
3269+
@check_figures_equal()
3270+
def test_errorbar_ecolor_cycle(fig_test, fig_ref):
3271+
x = np.arange(0.1, 4, 0.5)
3272+
y = [np.exp(-x+n) for n in range(4)]
3273+
3274+
axt = fig_test.subplots()
3275+
for yi in y:
3276+
axt.errorbar(x, yi, yerr= yi*0.25 , linestyle='-',
3277+
marker='o', ecolor='black')
3278+
3279+
axr = fig_ref.subplots()
3280+
for yi, color in zip(y, ['C0', 'C1', 'C2', 'C3']):
3281+
axr.errorbar(x, yi, yerr= yi*0.25, linestyle='-',
3282+
marker='o', color=color, ecolor='black')
3283+
32703284
@image_comparison(['hist_stacked_stepfilled', 'hist_stacked_stepfilled'])
32713285
def test_hist_stacked_stepfilled():
32723286
# make some data

0 commit comments

Comments
 (0)