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

Skip to content

Commit abe4117

Browse files
authored
Merge pull request #19872 from anntzer/eu
Fix unit handling in errorbar for astropy.
2 parents d8f04be + 4e16a84 commit abe4117

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3427,13 +3427,17 @@ def extract_err(name, err, data, lolims, uplims):
34273427
the note in the main docstring about this parameter's name.
34283428
"""
34293429
try:
3430-
low, high = np.broadcast_to(err, (2, len(data)))
3430+
np.broadcast_to(err, (2, len(data)))
34313431
except ValueError:
34323432
raise ValueError(
34333433
f"'{name}err' (shape: {np.shape(err)}) must be a scalar "
34343434
f"or a 1D or (2, n) array-like whose shape matches "
34353435
f"'{name}' (shape: {np.shape(data)})") from None
3436-
return data - low * ~lolims, data + high * ~uplims # low, high
3436+
# This is like
3437+
# low, high = np.broadcast_to(...)
3438+
# return data - low * ~lolims, data + high * ~uplims
3439+
# except that broadcast_to would strip units.
3440+
return data + np.row_stack([-(1 - lolims), 1 - uplims]) * err
34373441

34383442
if xerr is not None:
34393443
left, right = extract_err('x', xerr, x, xlolims, xuplims)

0 commit comments

Comments
 (0)