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

[Bug]: plt.errorbar error for all-nan xerr and yerr #25549

Closed as not planned
Closed as not planned
@Nanta-Sp

Description

@Nanta-Sp

Bug summary

plt.errorbar don't give result when only nan data in the xerr or yerr. This is similar to issue#24127.

Code for reproduction

importnumpyasnpimportmatplotlib.pyplotaspltplt.errorbar(x=[0],y=[0],xerr=[np.nan],yerr=[np.nan])plt.show()

Actual outcome


StopIteration Traceback (most recent call last)
in
1 import numpy as np
2 import matplotlib.pyplot as plt
----> 3 plt.errorbar(x=[0], y=[0], xerr =[np.nan], yerr=[np.nan])
4 plt.show()

4 frames
/usr/local/lib/python3.9/dist-packages/matplotlib/pyplot.py in errorbar(x, y, yerr, xerr, fmt, ecolor, elinewidth, capsize, barsabove, lolims, uplims, xlolims, xuplims, errorevery, capthick, data, **kwargs)
2562 uplims=False, xlolims=False, xuplims=False, errorevery=1,
2563 capthick=None, *, data=None, **kwargs):
-> 2564 return gca().errorbar(
2565 x, y, yerr=yerr, xerr=xerr, fmt=fmt, ecolor=ecolor,
2566 elinewidth=elinewidth, capsize=capsize, barsabove=barsabove,

/usr/local/lib/python3.9/dist-packages/matplotlib/init.py in inner(ax, data, *args, **kwargs)
1440 def inner(ax, *args, data=None, **kwargs):
1441 if data is None:
-> 1442 return func(ax, *map(sanitize_sequence, args), **kwargs)
1443
1444 bound = new_sig.bind(ax, *args, **kwargs)

/usr/local/lib/python3.9/dist-packages/matplotlib/axes/_axes.py in errorbar(self, x, y, yerr, xerr, fmt, ecolor, elinewidth, capsize, barsabove, lolims, uplims, xlolims, xuplims, errorevery, capthick, **kwargs)
3530
3531 if xerr is not None and not isinstance(xerr, np.ndarray):
-> 3532 xerr = _upcast_err(xerr)
3533 if yerr is not None and not isinstance(yerr, np.ndarray):
3534 yerr = _upcast_err(yerr)

/usr/local/lib/python3.9/dist-packages/matplotlib/axes/_axes.py in _upcast_err(err)
3514 # location first on pandas objects so err[0] almost always
3515 # fails.
-> 3516 isinstance(cbook._safe_first_finite(err), np.ndarray)
3517 ):
3518 # Get the type of the first element

/usr/local/lib/python3.9/dist-packages/matplotlib/cbook/init.py in _safe_first_finite(obj, skip_nonfinite)
1713 "support generators as input")
1714 else:
-> 1715 return next(val for val in obj if safe_isfinite(val))
1716
1717

StopIteration:

Expected outcome

Plot nothing

Additional information

No response

Operating system

colab

Matplotlib Version

3.7.1

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp