使用Python绘制ODE,Isoclines

时间:2011-06-16 11:02:18

标签: python matplotlib ode

我正在寻找一个Python包,它允许我绘制类似于下面看到的Java applet的东西:

http://math.mit.edu/mathlets/mathlets/isoclines/

有人知道任何ODE绘图包吗?我可以使用Numpy,Matplotlib从头开始编写代码,但我想先问一下。

谢谢,

3 个答案:

答案 0 :(得分:2)

Sage会这样做:

x,y = var("x y")
eq = y^3-3*y-x
p = implicit_plot(eq==0,(x,-4,4),(y,-4,4))
p += plot_slope_field(eq, (x,-4,4),(y,-4,4), headlength=1e-8)
p.show(aspect_ratio=1)

虽然它只是为图形包装matplotlib功能。 (说实话,matplotlib包装不是那么好,这常常让我感到头痛。)

example

答案 1 :(得分:2)

我写了这样的东西,似乎适用于y'= y ^ 2-x

from pylab import *
xmax = 4.0
xmin = -xmax
D = 20
ymax = 4.0
ymin = -ymax
x = linspace(xmin, xmax, D)
y = linspace(ymin, ymax, D)
X, Y = meshgrid(x, y)
deg = arctan(Y**2 - X)
QP = quiver(X,Y,cos(deg),sin(deg))
show()

enter image description here

答案 2 :(得分:0)

这些答案无法使用拖动工具更改参数。如果您需要此选项,那么这两个示例动态系统将向您展示如何。它们是用Python Sage编写的。只需将其视为具有许多预先制作的数学函数的Python。


Sage Example 1--phase plot
Sage Example 2--trajectory plot