Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5dc0474

Browse filesBrowse files
tacaswellMeeseeksDev[bot]
authored andcommitted
Backport PR #13209: Deprecate support for (n, 1)-shaped error arrays in errorbar().
1 parent a1a62b4 commit 5dc0474
Copy full SHA for 5dc0474

File tree

Expand file treeCollapse file tree

3 files changed

+20
-4
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+20
-4
lines changed
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Deprecations
2+
````````````
3+
4+
Support for passing (n, 1)-shaped error arrays to errorbar(), which was not
5+
documented and did not work for ``n = 2``, is deprecated (pass a 1D array
6+
instead).

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3309,6 +3309,12 @@ def extract_err(err, data):
33093309
or len(b_sh) > 2 or (len(b_sh) == 2 and b_sh[1] != 1)):
33103310
raise ValueError(
33113311
"err must be a scalar or a 1D or (2, n) array-like")
3312+
if len(a_sh) == 2 or len(b_sh) == 2:
3313+
cbook.warn_deprecated(
3314+
"3.1", message="Support for passing a (n, 1)-shaped error "
3315+
"array to errorbar() is deprecated since Matplotlib "
3316+
"%(since)s and will be removed %(removal)s; pass a 1D "
3317+
"array instead.")
33123318
# Using list comprehensions rather than arrays to preserve units.
33133319
for e in [a, b]:
33143320
if len(data) != len(e):

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2838,7 +2838,8 @@ def test_errorbar():
28382838
fig, axs = plt.subplots(nrows=2, ncols=2, sharex=True)
28392839
ax = axs[0, 0]
28402840
# Try a Nx1 shaped error just to check
2841-
ax.errorbar(x, y, yerr=np.reshape(yerr, (len(y), 1)), fmt='o')
2841+
with pytest.warns(MatplotlibDeprecationWarning):
2842+
ax.errorbar(x, y, yerr=np.reshape(yerr, (len(y), 1)), fmt='o')
28422843
ax.set_title('Vert. symmetric')
28432844

28442845
# With 4 subplots, reduce the number of axis ticks to avoid crowding.
@@ -5216,9 +5217,12 @@ def generate_errorbar_inputs():
52165217

52175218
@pytest.mark.parametrize('kwargs', generate_errorbar_inputs())
52185219
def test_errorbar_inputs_shotgun(kwargs):
5219-
ax = plt.gca()
5220-
eb = ax.errorbar(**kwargs)
5221-
eb.remove()
5220+
with warnings.catch_warnings():
5221+
# (n, 1)-shaped error deprecation already tested by test_errorbar.
5222+
warnings.simplefilter("ignore", MatplotlibDeprecationWarning)
5223+
ax = plt.gca()
5224+
eb = ax.errorbar(**kwargs)
5225+
eb.remove()
52225226

52235227

52245228
@image_comparison(baseline_images=["dash_offset"], remove_text=True)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.