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

Skip to content
Closed
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
36 changes: 27 additions & 9 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2965,13 +2965,24 @@ def _bool_asarray_helper(d, expected):

def xywhere(xs, ys, mask):
"""
return xs[mask], ys[mask] where mask is True but xs and
ys are not arrays
Return xs[mask], ys[mask] where mask is True but xs and
ys are not arrays.

If they are arrays, just return xs[mask] and ys[mask].
"""
assert len(xs) == len(ys)
assert len(xs) == len(mask)
xs = [thisx for thisx, b in zip(xs, mask) if b]
ys = [thisy for thisy, b in zip(ys, mask) if b]

if isinstance(xs, np.ndarray):
xs = xs[mask]
else:
xs = [thisx for thisx, b in zip(xs, mask) if b]

if isinstance(ys, np.ndarray):
ys = ys[mask]
else:
ys = [thisy for thisy, b in zip(ys, mask) if b]

return xs, ys

def extract_err(err, data):
Expand Down Expand Up @@ -3005,11 +3016,18 @@ def extract_err(err, data):
if (len(err) != len(data) or np.size(fe) > 1):
raise ValueError("err must be [ scalar | N, Nx1 "
"or 2xN array-like ]")
# using list comps rather than arrays to preserve units
low = [thisx - thiserr for (thisx, thiserr)
in cbook.safezip(data, err)]
high = [thisx + thiserr for (thisx, thiserr)
in cbook.safezip(data, err)]
if isinstance(data, np.ndarray):
low = data - err
else:
# using list comps rather than arrays to preserve units
low = [thisx - thiserr for (thisx, thiserr)
in cbook.safezip(data, err)]
if isinstance(data, np.ndarray):
high = data + err
else:
# using list comps rather than arrays to preserve units
high = [thisx + thiserr for (thisx, thiserr)
in cbook.safezip(data, err)]
return low, high

if xerr is not None:
Expand Down