Reputation: 37
I'm trying to make a quiver plot in Jupyter Notebook but I'm getting a TypeError the way I'm defining my u,v arrays. I have an array ug
with the velocity norm (it only has x-component) so I'm doing:
ug = [0.0 0.072 0.128 0.16800000000000004 0.19200000000000006 0.20000000000000007 0.19200000000000006 0.16800000000000004 0.128 0.07200000000000001 1.734723475976807e-17]
xg = np.linspace(0,l,int(l/50))
yg = np.linspace(0,d,len(ug))
(Xg,Yg) = np.meshgrid(xg,yg)
(Vg,Ug) = np.meshgrid(0*xg,ug)
plt.quiver(Xg,Yg,Ug,Vg)
The last line, the call to quiver
, raises the following error:
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''
Why does quiver
reject these arrays?
Upvotes: 0
Views: 347
Reputation: 37
It seems that ug
must be a list, instead of a np.array. I've changed:
ug = list(ud[::4])
and it works!
Upvotes: 1