Skip to content

Commit e3f86ad

Browse files
committed
add validator to errorbar method
1 parent 43cbd82 commit e3f86ad

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3283,6 +3283,11 @@ def errorbar(self, x, y, yerr=None, xerr=None,
32833283
x, y = np.atleast_1d(x, y) # Make sure all the args are iterable.
32843284
if len(x) != len(y):
32853285
raise ValueError("'x' and 'y' must have the same size")
3286+
3287+
if xerr is not None and np.any(xerr < 0):
3288+
raise ValueError("'xerr' must have positive numbers")
3289+
if yerr is not None and np.any(yerr < 0):
3290+
raise ValueError("'yerr' must have positive numbers")
32863291

32873292
if isinstance(errorevery, Integral):
32883293
errorevery = (0, errorevery)

0 commit comments

Comments
 (0)