Skip to content

Commit 36d5d78

Browse files
committed
Remove support for non-1D errorbars.
1 parent 3270153 commit 36d5d78

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

doc/api/api_changes_3.3/removals.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ Arguments
221221
- `.MaxNLocator.set_params()` no longer accepts arbitrary keyword arguments.
222222
- `~.Axes.pie` no longer accepts and squeezes non-1D inputs; pass 1D input to
223223
the ``x`` argument.
224+
- Passing (n, 1)-shaped error arrays to `.Axes.errorbar()` is no longer
225+
supported; pass a 1D array instead.
224226

225227
rcParams
226228
~~~~~~~~

lib/matplotlib/axes/_axes.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3368,7 +3368,7 @@ def xywhere(xs, ys, mask):
33683368
ys = [thisy for thisy, b in zip(ys, mask) if b]
33693369
return xs, ys
33703370

3371-
def extract_err(err, data):
3371+
def extract_err(name, err, data):
33723372
"""
33733373
Private function to parse *err* and subtract/add it to *data*.
33743374
@@ -3380,20 +3380,9 @@ def extract_err(err, data):
33803380
iter(b)
33813381
except (TypeError, ValueError):
33823382
a = b = err # Symmetric error: 1D iterable.
3383-
# This could just be `np.ndim(a) > 1 and np.ndim(b) > 1`, except
3384-
# for the (undocumented, but tested) support for (n, 1) arrays.
3385-
a_sh = np.shape(a)
3386-
b_sh = np.shape(b)
3387-
if (len(a_sh) > 2 or (len(a_sh) == 2 and a_sh[1] != 1)
3388-
or len(b_sh) > 2 or (len(b_sh) == 2 and b_sh[1] != 1)):
3383+
if np.ndim(a) > 1 or np.ndim(b) > 1:
33893384
raise ValueError(
3390-
"err must be a scalar or a 1D or (2, n) array-like")
3391-
if len(a_sh) == 2 or len(b_sh) == 2:
3392-
cbook.warn_deprecated(
3393-
"3.1", message="Support for passing a (n, 1)-shaped error "
3394-
"array to errorbar() is deprecated since Matplotlib "
3395-
"%(since)s and will be removed %(removal)s; pass a 1D "
3396-
"array instead.")
3385+
f"{name}err must be a scalar or a 1D or (2, n) array-like")
33973386
# Using list comprehensions rather than arrays to preserve units.
33983387
for e in [a, b]:
33993388
if len(data) != len(e):
@@ -3405,7 +3394,7 @@ def extract_err(err, data):
34053394
return low, high
34063395

34073396
if xerr is not None:
3408-
left, right = extract_err(xerr, x)
3397+
left, right = extract_err('x', xerr, x)
34093398
# select points without upper/lower limits in x and
34103399
# draw normal errorbars for these points
34113400
noxlims = ~(xlolims | xuplims)
@@ -3454,7 +3443,7 @@ def extract_err(err, data):
34543443
**eb_cap_style))
34553444

34563445
if yerr is not None:
3457-
lower, upper = extract_err(yerr, y)
3446+
lower, upper = extract_err('y', yerr, y)
34583447
# select points without upper/lower limits in y and
34593448
# draw normal errorbars for these points
34603449
noylims = ~(lolims | uplims)

0 commit comments

Comments
 (0)