Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Milestone
Description
Bug summary
The functionax.errorbar
raises aStopIteration
error whenyerr
contains onlyNaN
values.
Code for reproduction
importmatplotlib.pyplotaspltimportnumpyasnpfig,ax=plt.subplots(1,1)ax.errorbar([0], [0], [np.nan])
Actual outcome
Traceback (most recent call last): File"<stdin>", line 1,in<module> File"~/.local/share/virtualenvs/pipeline/lib/python3.9/site-packages/matplotlib/__init__.py", line 1423,in innerreturn func(ax,*map(sanitize_sequence, args),**kwargs) File"~.local/share/virtualenvs/pipeline/lib/python3.9/site-packages/matplotlib/axes/_axes.py", line 3488,in errorbar yerr = _upcast_err(yerr) File"~/.local/share/virtualenvs/pipeline/lib/python3.9/site-packages/matplotlib/axes/_axes.py", line 3470,in _upcast_err isinstance(cbook._safe_first_finite(err), np.ndarray) File"~/.local/share/virtualenvs/pipeline/lib/python3.9/site-packages/matplotlib/cbook/__init__.py", line 1749,in _safe_first_finitereturn next(valforvalin objif safe_isfinite(val))StopIteration
Expected outcome
No crash, similar to the case where only some values are NaN.
Additional information
This happens because_upcast_err
unconditionally looks for a first finite element inxerr
andyerr
.
Operating system
Debian
Matplotlib Version
3.6.2
Matplotlib Backend
TkAgg
Python version
3.9.2
Jupyter version
No response
Installation
pip
Metadata
Metadata
Assignees
Labels
No labels