Hi,
trying to create a velocity plot for a 2d ode and superimposing it onto
a trajectory, I am encountering some issues with quiver.
Let ns1(x,t) be a vector function defining the ode, ready to be integrated with
scipy odeint and actually invariant with t. Here, x is a 1d state array with 2
entries.
I get the velocity field by first creating vectors of interesting points on the
two axis, say xg and yg. Then I make a grid with
xxg, yyg = np.meshgrid(xg, yg)
and I finally compute the velocity components as
vel = np.asarray(map(lambda x1, x2: ns1((x1,x2),0), xxg.flat, yyg.flat))
u=vel[:,0]
v=vel[:,1]
Now, I try to superimpose a trajectory with the velocity plot.
However, after having plotted the integrated trajectory, I cannot call
plt.quiver(xxg, yyg, u, v)
because the u and v components have very different ranges.
Trying to normalize as
plt.quiver(xxg, yyg, u/xrange, v/yrange)
looks (almost) right, but it is not nice to have to precompute the ranges.
I was expecting
plt.quiver(xxg, yyg, u, v, angles='xy')
to do the job automatically, but this is not the case.
For points with null x coordinate my arrows always have null length,
while this was not the case with the previous test.
any clue?