Skip to content

Commit

Permalink
close #16593: setting ecolor turns off color cycling (#16597)
Browse files Browse the repository at this point in the history
* closes #16593 setting ecolor turns off color cycling
Co-authored-by: tacaswell <tcaswell@gmail.com>

* added api change

* ~.Axes, not ~Axes
  • Loading branch information
story645 committed Mar 1, 2020
1 parent ed79353 commit 12f2624
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
8 changes: 8 additions & 0 deletions doc/api/next_api_changes/behaviour.rst
Expand Up @@ -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.
3 changes: 1 addition & 2 deletions lib/matplotlib/axes/_axes.py
Expand Up @@ -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')
Expand Down
15 changes: 15 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Expand Up @@ -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()
Expand Down

0 comments on commit 12f2624

Please sign in to comment.