Hi everyone,
can someone please help me how to make a plot like this:
http://tutorial.math.lamar.edu/Classes/DE/PhasePlane_files/image002.gif
The main issue with it is in the (black) trajectories. As far as i know
there is no function in matplotlib to plot trajectories with arrows
pointing in a direction.
But I think a good workaround is: plotting the trajectories with plot(..)
and use quiver(..) at certain points to get an arrows.
A minimal example would be:
import matplotlib.pyplot as plt
import numpy as np
import scipy.integrate as integrate
if __name__=="__main__":
t = np.linspace(0, 20, 1000)
l = 3
# some starting points
X0s = [[-3.0, 0],
[-3.0, -1],
[-3.0, -2],
[-2, -3.0],
[-1, -3.0],
[0, -3.0],
[1, -3.0],
[2, -3.0],
[3.0, -2],
[3.0, -1],
[3.0, 0.0],
[3.0, 1],
[3.0, 2],
[2, 3.0],
[1, 3.0],
[0, 3.0],
[-1, 3.0],
[-2, 3.0],
[-3.0, 2],
[-3.0, 1],
[0, 0.01],
[0, -0.01],
[0.01, 0],
[-0.01, 0]]
sattel = lambda x,t=0: [-x[0], x[1]]
plt.axis([-l,l,-l,l])
for X0 in X0s:
state = integrate.odeint(sattel, X0, t).T
plt.plot(*state, color="k", linewidth=1)
xs = state[:,::10]
x_ds = np.asarray(sattel(xs))
M = np.hypot(x_ds[0],x_ds[1])
plt.quiver(xs[0],xs[1],x_ds[0]/M,x_ds[1]/M,
pivot="mid")#,scale=100, scale_units="width",linewidth=5)
plt.axis([-l,l,-l,l])
plt.show()
That is pretty much what I was looking for except the shafts of the arrows
that I can't get rid off.
You can see what I tried to get this done by uncomment the quiver parameter.
Doing this, you can see, the shafts are (nearly) gone, but the arrows look
horrible. I wonder if there is anyway to tell quiver(..) to only plot the
heads of the arrow, without the shaft.
Can you please give me a hint how to do this?
Thank you,
Andy
Matplotlib version: 1.0.1
Installed as: Ubuntu package
OS: Ubuntu 11.10
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users