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

Plotting with fill_between and timedelta on yaxis throws TypeError #8352

Closed as not planned
@SebastianRzk

Description

@SebastianRzk

Bug report

Hi everyone,
I don't know whether it is a bug or a missing feature in numpy or matplotlib, but plotting with fill_between and a simpledatetime.timedelta (x axis) throws the following exception:

TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Here is a simple (runnable) example:

fromdatetimeimporttimedeltafrommatplotlibimportpyplotfrompandasimportDataFrameif__name__=='__main__':df=DataFrame([[timedelta(seconds=0),4], [timedelta(seconds=10),5]],columns=['TIME','VALUE'])df=df.set_index('TIME')pyplot.fill_between(df.index,0,df.VALUE)

Full stacktrace:

Traceback (most recent call last):  File "/de/test.py", line 11, in <module>    pyplot.fill_between(df.TIME, 0, df.VALUE)  File "/usr/lib/python3.6/site-packages/matplotlib/pyplot.py", line 2896, in fill_between    **kwargs)  File "/usr/lib/python3.6/site-packages/matplotlib/__init__.py", line 1819, in inner    return func(ax, *args, **kwargs)  File "/usr/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 4581, in fill_between    x = ma.masked_invalid(self.convert_xunits(x))  File "/usr/lib/python3.6/site-packages/numpy/ma/core.py", line 2340, in masked_invalid    condition = ~(np.isfinite(a))TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

With dates, everthing works as expected:

frommatplotlibimportpyplotfrompandasimportDataFrameimportpandasif__name__=='__main__':df=DataFrame([[1488364614802,4], [1488364615802,5]],columns=['TIME','VALUE'])df.TIME=pandas.to_datetime(df.TIME,unit='ms')df=df.set_index('TIME')print(df)pyplot.fill_between(df.index,0,df.VALUE)

Matplotlib version
Matplotlub version: Version: 2.0.0 (via pip)
Python 3.6.0
Plattform: Linux 4.10.1-1 x86_64

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