Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit1e8286d

Browse files
authored
Merge pull request#21362 from timhoffm/errorbar-note
Simplify wording of allowed errorbar() error values
2 parents60466fb +977bff2 commit1e8286d

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

‎lib/matplotlib/axes/_axes.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3181,7 +3181,7 @@ def errorbar(self, x, y, yerr=None, xerr=None,
31813181
errors.
31823182
- *None*: No errorbar.
31833183
3184-
Note that all error arrays should have *non-negative* values.
3184+
All values must be >= 0.
31853185
31863186
See :doc:`/gallery/statistics/errorbar_features`
31873187
for an example on the usage of ``xerr`` and ``yerr``.
@@ -3293,9 +3293,10 @@ def has_negative_values(array):
32933293
exceptTypeError:# if array contains 'datetime.timedelta' types
32943294
returnnp.any(array<timedelta(0))
32953295

3296-
ifhas_negative_values(xerr)orhas_negative_values(yerr):
3297-
raiseValueError(
3298-
"'xerr' and 'yerr' must have non-negative values")
3296+
ifhas_negative_values(xerr):
3297+
raiseValueError("'xerr' must not contain negative values")
3298+
ifhas_negative_values(yerr):
3299+
raiseValueError("'yerr' must not contain negative values")
32993300

33003301
ifisinstance(errorevery,Integral):
33013302
errorevery= (0,errorevery)

‎lib/matplotlib/tests/test_axes.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3514,18 +3514,20 @@ def test_errorbar_every_invalid():
35143514
ax.errorbar(x,y,yerr,errorevery='foobar')
35153515

35163516

3517-
deftest_xerr_yerr_positive():
3517+
deftest_xerr_yerr_not_negative():
35183518
ax=plt.figure().subplots()
35193519

3520-
error_message="'xerr' and 'yerr' must have non-negative values"
3521-
3522-
withpytest.raises(ValueError,match=error_message):
3520+
withpytest.raises(ValueError,
3521+
match="'xerr' must not contain negative values"):
35233522
ax.errorbar(x=[0],y=[0],xerr=[[-0.5], [1]],yerr=[[-0.5], [1]])
3524-
withpytest.raises(ValueError,match=error_message):
3523+
withpytest.raises(ValueError,
3524+
match="'xerr' must not contain negative values"):
35253525
ax.errorbar(x=[0],y=[0],xerr=[[-0.5], [1]])
3526-
withpytest.raises(ValueError,match=error_message):
3526+
withpytest.raises(ValueError,
3527+
match="'yerr' must not contain negative values"):
35273528
ax.errorbar(x=[0],y=[0],yerr=[[-0.5], [1]])
3528-
withpytest.raises(ValueError,match=error_message):
3529+
withpytest.raises(ValueError,
3530+
match="'yerr' must not contain negative values"):
35293531
x=np.arange(5)
35303532
y= [datetime.datetime(2021,9,i*2+1)foriinx]
35313533
ax.errorbar(x=x,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp