Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

close #16593: setting ecolor turns off color cycling #16597

Merged
merged 3 commits into from Mar 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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