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

Skip to content

FIX: add errorbars with add_container #29401

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

Merged
merged 1 commit into from
Jan 6, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3853,7 +3853,7 @@ def apply_mask(arrays, mask):
(data_line, tuple(caplines), tuple(barcols)),
has_xerr=(xerr is not None), has_yerr=(yerr is not None),
label=label)
self.containers.append(errorbar_container)
self.add_container(errorbar_container)

return errorbar_container # (l0, caplines, barcols)

Expand Down
18 changes: 18 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4274,6 +4274,24 @@ def test_errorbar_nonefmt():
assert np.all(errbar.get_color() == mcolors.to_rgba('C0'))


def test_errorbar_remove():
x = np.arange(5)
y = np.arange(5)

fig, ax = plt.subplots()
ec = ax.errorbar(x, y, xerr=1, yerr=1)

assert len(ax.containers) == 1
assert len(ax.lines) == 5
assert len(ax.collections) == 2

ec.remove()

assert not ax.containers
assert not ax.lines
assert not ax.collections


def test_errorbar_line_specific_kwargs():
# Check that passing line-specific keyword arguments will not result in
# errors.
Expand Down
Loading