Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c43f4fd

Browse filesBrowse files
committed
FIX: in errorbar discard any kwargs which have None value
Passing in `None` is a request from the user to 'do the default thing', but by keeping the key:value in the kwargs dict it prevents the default errorbar behavior and falls through to default Line2D behavior which is likely not what is wanted. closes #7899
1 parent 013fd3f commit c43f4fd
Copy full SHA for c43f4fd

File tree

Expand file treeCollapse file tree

2 files changed

+19
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-0
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2798,6 +2798,9 @@ def errorbar(self, x, y, yerr=None, xerr=None,
27982798
.. plot:: mpl_examples/statistics/errorbar_demo.py
27992799
"""
28002800
kwargs = cbook.normalize_kwargs(kwargs, _alias_map)
2801+
# anything that comes in as 'None', drop so the default thing
2802+
# happens down stream
2803+
kwargs = {k: v for k, v in kwargs.items() if v is not None}
28012804
kwargs.setdefault('zorder', 2)
28022805

28032806
if errorevery < 1:

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2365,6 +2365,22 @@ def test_errorbar():
23652365
ax.set_title("Simplest errorbars, 0.2 in x, 0.4 in y")
23662366

23672367

2368+
@cleanup
2369+
def test_errorbar_colorcycle():
2370+
2371+
f, ax = plt.subplots()
2372+
x = np.arange(10)
2373+
y = 2*x
2374+
2375+
e1, _, _ = ax.errorbar(x, y, c=None)
2376+
e2, _, _ = ax.errorbar(x, 2*y, c=None)
2377+
ln1, = ax.plot(x, 4*y)
2378+
2379+
assert mcolors.to_rgba(e1.get_color()) == mcolors.to_rgba('C0')
2380+
assert mcolors.to_rgba(e2.get_color()) == mcolors.to_rgba('C1')
2381+
assert mcolors.to_rgba(ln1.get_color()) == mcolors.to_rgba('C2')
2382+
2383+
23682384
@cleanup
23692385
def test_errorbar_shape():
23702386
fig = plt.figure()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.