TypeError: ufunc 'isfinite' not supported for the input - in matplotlib stackplot
See original GitHub issueThe following code, which calls stackplot twice, works on the first but fails on the second. On the call to the second the int list looks exactly the same.
Numpy 1.10.4 Matplotlib 1.5.1 Python 3.5.1
import sys
import numpy as np
import pandas as pd
import random
import matplotlib.pyplot as plt
plt.ion()
period = 36
ward_dates = pd.date_range(start=pd.datetime.today(), freq='M', periods=period)
list_size = 6
ward_counts = [[] for i in range(list_size)]
for idx in range(list_size):
current_list = [np.random.randint(0, 500000) for r in range(period)]
ward_counts[idx] = current_list
plt.stackplot(ward_dates, ward_counts)
plt.close('all')
units = np.random.choice(['U1', 'U2', 'U3'], size=period)
index = pd.MultiIndex.from_arrays([units, ward_dates])
s1 = pd.Series([np.random.randint(0, 5000) for r in range(period)], index=index)
ward_counts = [[] for i in range(3)]
l1 = [int(x) for x in s1.loc['U1'].values]
ward_counts[0] = l1
l1 = [int(x) for x in s1.loc['U2'].values]
ward_counts[1] = l1
l1 = [int(x) for x in s1.loc['U3'].values]
ward_counts[2] = l1
plt.stackplot(ward_dates, ward_counts)`
Error trackback is
Traceback (most recent call last):
File "<input>", line 29, in <module>
File "C:\Users\dgrawroc\Documents\Anaconda3\envs\m2\lib\site-packages\matplotlib\pyplot.py", line 3326, in stackplot
ret = ax.stackplot(x, *args, **kwargs)
File "C:\Users\dgrawroc\Documents\Anaconda3\envs\m2\lib\site-packages\matplotlib\__init__.py", line 1811, in inner
return func(ax, *args, **kwargs)
File "C:\Users\dgrawroc\Documents\Anaconda3\envs\m2\lib\site-packages\matplotlib\axes\_axes.py", line 4443, in stackplot
return mstack.stackplot(self, x, *args, **kwargs)
File "C:\Users\dgrawroc\Documents\Anaconda3\envs\m2\lib\site-packages\matplotlib\stackplot.py", line 113, in stackplot
**kwargs))
File "C:\Users\dgrawroc\Documents\Anaconda3\envs\m2\lib\site-packages\matplotlib\__init__.py", line 1811, in inner
return func(ax, *args, **kwargs)
File "C:\Users\dgrawroc\Documents\Anaconda3\envs\m2\lib\site-packages\matplotlib\axes\_axes.py", line 4608, in fill_between
y2 = ma.masked_invalid(self.convert_yunits(y2))
File "C:\Users\dgrawroc\Documents\Anaconda3\envs\m2\lib\site-packages\numpy\ma\core.py", line 2293, 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''
Issue Analytics
- State:
- Created 8 years ago
- Comments:13 (4 by maintainers)
Top Results From Across the Web
Stackplot "TypeError: ufunc 'isfinite' not supported for the input ...
So I copied the data from the output to try to replicate the error, doing data = [copied data] and plt.stackplot(np.arange(2013, 2051, 1),...
Read more >ufunc 'isfinite' not supported for the input types - You.com
Python Numpy TypeError: ufunc 'isfinite' not supported for the input types ... i am trying to make a plot following this example, for...
Read more >TypeError: ufunc 'isfinite' not supported for the input types...
I have a short piece of coding (Python 3.5.3) which reads from a small MySQL database table. Code: Select all #!/usr/bin/env python3 from...
Read more >I cant fill the space between two lines "TypeError: ufunc 'isfinite ...
The program is supposed to determine the area between two input equations ... TypeError: ufunc 'isfinite' not supported for the input types, ...
Read more >Python – Numpy isfinite typeerror – iTecNote
numpypython ... below results in TypeError: ufunc 'isfinite' not supported for the input type. ... return mstack.stackplot(self, x, *args, **kwargs) File ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
when I run this part of my code, this error appeared ,I don’t know whats the problem? when i run it for year 2019 that exist in my data set, the figure was shown ,but it doesn’t show the prediction year’2020’
Numerical types should go through fine, but object type for example should fail like this. So Probably got an object array somewhere, could also be a lengths mismatch somewhere.