<h3 dir="auto">Bug summary</h3>
<p dir="auto"><code class="notranslate">plt.errorbar</code> don't give result when only nan data in the xerr or yerr. This is similar to issue <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1401925305" data-permission-text="Title is private" data-url="https://github.com/matplotlib/matplotlib/issues/24127" data-hovercard-type="issue" data-hovercard-url="/matplotlib/matplotlib/issues/24127/hovercard" href="https://github.com/matplotlib/matplotlib/issues/24127">#24127</a>.</p>
<h3 dir="auto">Code for reproduction</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
import matplotlib.pyplot as plt
plt.errorbar(x=[0], y=[0], xerr =[np.nan], yerr=[np.nan])
plt.show()"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-s1">plt</span>.<span class="pl-en">errorbar</span>(<span class="pl-s1">x</span><span class="pl-c1">=</span>[<span class="pl-c1">0</span>], <span class="pl-s1">y</span><span class="pl-c1">=</span>[<span class="pl-c1">0</span>], <span class="pl-s1">xerr</span> <span class="pl-c1">=</span>[<span class="pl-s1">np</span>.<span class="pl-s1">nan</span>], <span class="pl-s1">yerr</span><span class="pl-c1">=</span>[<span class="pl-s1">np</span>.<span class="pl-s1">nan</span>])
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<h3 dir="auto">Actual outcome</h3>
<blockquote>
<hr>
</blockquote>
<p dir="auto">StopIteration                             Traceback (most recent call last)<br>
<a href="https://localhost:8080/#" rel="nofollow"></a> in <br>
1 import numpy as np<br>
2 import matplotlib.pyplot as plt<br>
----&gt; 3 plt.errorbar(x=[0], y=[0], xerr =[np.nan], yerr=[np.nan])<br>
4 plt.show()</p>
<p dir="auto">4 frames<br>
<a href="https://localhost:8080/#" rel="nofollow">/usr/local/lib/python3.9/dist-packages/matplotlib/pyplot.py</a> in errorbar(x, y, yerr, xerr, fmt, ecolor, elinewidth, capsize, barsabove, lolims, uplims, xlolims, xuplims, errorevery, capthick, data, **kwargs)<br>
2562         uplims=False, xlolims=False, xuplims=False, errorevery=1,<br>
2563         capthick=None, *, data=None, **kwargs):<br>
-&gt; 2564     return gca().errorbar(<br>
2565         x, y, yerr=yerr, xerr=xerr, fmt=fmt, ecolor=ecolor,<br>
2566         elinewidth=elinewidth, capsize=capsize, barsabove=barsabove,</p>
<p dir="auto"><a href="https://localhost:8080/#" rel="nofollow">/usr/local/lib/python3.9/dist-packages/matplotlib/<strong>init</strong>.py</a> in inner(ax, data, *args, **kwargs)<br>
1440     def inner(ax, *args, data=None, **kwargs):<br>
1441         if data is None:<br>
-&gt; 1442             return func(ax, *map(sanitize_sequence, args), **kwargs)<br>
1443<br>
1444         bound = new_sig.bind(ax, *args, **kwargs)</p>
<p dir="auto"><a href="https://localhost:8080/#" rel="nofollow">/usr/local/lib/python3.9/dist-packages/matplotlib/axes/_axes.py</a> in errorbar(self, x, y, yerr, xerr, fmt, ecolor, elinewidth, capsize, barsabove, lolims, uplims, xlolims, xuplims, errorevery, capthick, **kwargs)<br>
3530<br>
3531         if xerr is not None and not isinstance(xerr, np.ndarray):<br>
-&gt; 3532             xerr = _upcast_err(xerr)<br>
3533         if yerr is not None and not isinstance(yerr, np.ndarray):<br>
3534             yerr = _upcast_err(yerr)</p>
<p dir="auto"><a href="https://localhost:8080/#" rel="nofollow">/usr/local/lib/python3.9/dist-packages/matplotlib/axes/_axes.py</a> in _upcast_err(err)<br>
3514                     # location first on pandas objects so err[0] almost always<br>
3515                     # fails.<br>
-&gt; 3516                     isinstance(cbook._safe_first_finite(err), np.ndarray)<br>
3517             ):<br>
3518                 # Get the type of the first element</p>
<p dir="auto"><a href="https://localhost:8080/#" rel="nofollow">/usr/local/lib/python3.9/dist-packages/matplotlib/cbook/<strong>init</strong>.py</a> in _safe_first_finite(obj, skip_nonfinite)<br>
1713                            "support generators as input")<br>
1714     else:<br>
-&gt; 1715         return next(val for val in obj if safe_isfinite(val))<br>
1716<br>
1717</p>
<p dir="auto">StopIteration:</p>
<h3 dir="auto">Expected outcome</h3>
<p dir="auto">Plot nothing</p>
<h3 dir="auto">Additional information</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Operating system</h3>
<p dir="auto">colab</p>
<h3 dir="auto">Matplotlib Version</h3>
<p dir="auto">3.7.1</p>
<h3 dir="auto">Matplotlib Backend</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Python version</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Jupyter version</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Installation</h3>
<p dir="auto">None</p>
<h3 dir="auto">Bug summary</h3>
<p dir="auto">The function <code class="notranslate">ax.errorbar</code> raises a <code class="notranslate">StopIteration</code> error when <code class="notranslate">yerr</code> contains only <code class="notranslate">NaN</code> values.</p>
<h3 dir="auto">Code for reproduction</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots(1, 1)
ax.errorbar([0], [0], [np.nan])"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-s1">fig</span>, <span class="pl-s1">ax</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">subplots</span>(<span class="pl-c1">1</span>, <span class="pl-c1">1</span>)
<span class="pl-s1">ax</span>.<span class="pl-en">errorbar</span>([<span class="pl-c1">0</span>], [<span class="pl-c1">0</span>], [<span class="pl-s1">np</span>.<span class="pl-s1">nan</span>])</pre></div>
<h3 dir="auto">Actual outcome</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
  File &quot;~/.local/share/virtualenvs/pipeline/lib/python3.9/site-packages/matplotlib/__init__.py&quot;, line 1423, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File &quot;~.local/share/virtualenvs/pipeline/lib/python3.9/site-packages/matplotlib/axes/_axes.py&quot;, line 3488, in errorbar
    yerr = _upcast_err(yerr)
  File &quot;~/.local/share/virtualenvs/pipeline/lib/python3.9/site-packages/matplotlib/axes/_axes.py&quot;, line 3470, in _upcast_err
    isinstance(cbook._safe_first_finite(err), np.ndarray)
  File &quot;~/.local/share/virtualenvs/pipeline/lib/python3.9/site-packages/matplotlib/cbook/__init__.py&quot;, line 1749, in _safe_first_finite
    return next(val for val in obj if safe_isfinite(val))
StopIteration"><pre class="notranslate">Traceback (most recent call last):
  File <span class="pl-s"><span class="pl-pds">"</span>&lt;stdin&gt;<span class="pl-pds">"</span></span>, line 1, <span class="pl-k">in</span> <span class="pl-k">&lt;</span>module<span class="pl-k">&gt;</span>
  File <span class="pl-s"><span class="pl-pds">"</span>~/.local/share/virtualenvs/pipeline/lib/python3.9/site-packages/matplotlib/__init__.py<span class="pl-pds">"</span></span>, line 1423, <span class="pl-k">in</span> inner
    <span class="pl-k">return</span> func(ax, <span class="pl-k">*</span>map(sanitize_sequence, args), <span class="pl-k">**</span>kwargs)
  File <span class="pl-s"><span class="pl-pds">"</span>~.local/share/virtualenvs/pipeline/lib/python3.9/site-packages/matplotlib/axes/_axes.py<span class="pl-pds">"</span></span>, line 3488, <span class="pl-k">in</span> errorbar
    yerr = _upcast_err(yerr)
  File <span class="pl-s"><span class="pl-pds">"</span>~/.local/share/virtualenvs/pipeline/lib/python3.9/site-packages/matplotlib/axes/_axes.py<span class="pl-pds">"</span></span>, line 3470, <span class="pl-k">in</span> _upcast_err
    isinstance(cbook._safe_first_finite(err), np.ndarray)
  File <span class="pl-s"><span class="pl-pds">"</span>~/.local/share/virtualenvs/pipeline/lib/python3.9/site-packages/matplotlib/cbook/__init__.py<span class="pl-pds">"</span></span>, line 1749, <span class="pl-k">in</span> _safe_first_finite
    <span class="pl-k">return</span> next(val <span class="pl-k">for</span> <span class="pl-smi">val</span> <span class="pl-k">in</span> obj <span class="pl-k">if</span> safe_isfinite(val))
StopIteration</pre></div>
<h3 dir="auto">Expected outcome</h3>
<p dir="auto">No crash, similar to the case where only some values are NaN.</p>
<h3 dir="auto">Additional information</h3>
<p dir="auto">This happens because  <code class="notranslate">_upcast_err</code> unconditionally looks for a first finite element in <code class="notranslate">xerr</code> and <code class="notranslate">yerr</code>.</p>
<h3 dir="auto">Operating system</h3>
<p dir="auto">Debian</p>
<h3 dir="auto">Matplotlib Version</h3>
<p dir="auto">3.6.2</p>
<h3 dir="auto">Matplotlib Backend</h3>
<p dir="auto">TkAgg</p>
<h3 dir="auto">Python version</h3>
<p dir="auto">3.9.2</p>
<h3 dir="auto">Jupyter version</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Installation</h3>
<p dir="auto">pip</p>