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 as not planned
Labels
Description
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