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

Skip to content

FIX: ensure errorbar creates line collection even with empty data #9709

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
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
4 changes: 2 additions & 2 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3033,7 +3033,7 @@ def extract_err(err, data):
# select points without upper/lower limits in x and
# draw normal errorbars for these points
noxlims = ~(xlolims | xuplims)
if noxlims.any():
if noxlims.any() or len(noxlims) == 0:
yo, _ = xywhere(y, right, noxlims & everymask)
lo, ro = xywhere(left, right, noxlims & everymask)
barcols.append(self.hlines(yo, lo, ro, **eb_lines_style))
Expand Down Expand Up @@ -3082,7 +3082,7 @@ def extract_err(err, data):
# select points without upper/lower limits in y and
# draw normal errorbars for these points
noylims = ~(lolims | uplims)
if noylims.any():
if noylims.any() or len(noylims) == 0:
xo, _ = xywhere(x, lower, noylims & everymask)
lo, uo = xywhere(lower, upper, noylims & everymask)
barcols.append(self.vlines(xo, lo, uo, **eb_lines_style))
Expand Down
7 changes: 7 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5402,3 +5402,10 @@ def test_polar_gridlines():

assert ax.xaxis.majorTicks[0].gridline.get_alpha() == .2
assert ax.yaxis.majorTicks[0].gridline.get_alpha() == .2


def test_empty_errorbar_legend():
fig, ax = plt.subplots()
ax.errorbar([], [], xerr=[], label='empty y')
ax.errorbar([], [], yerr=[], label='empty x')
ax.legend()