2011-06-16 60 views
3

我要尋找一個Python包,讓我繪製類似於Java小程序的東西如下所示:繪製常微分方程,等值線使用Python

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

有誰知道任何ODE繪製這個包?我可以使用Numpy,Matplotlib從頭開始編寫代碼,但我想先問一下。

感謝,

+1

matplotlib的顫抖會做這樣的事情嗎? http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.quiver和http://matplotlib.sourceforge.net/examples/pylab_examples/quiver_demo.html – 2011-06-16 11:55:00

+0

是顫抖顯然可以幫助在這裏,我看到一些它的例子也是如此。 – user423805 2011-06-16 12:35:58

回答

2

我寫了這樣的事情,它似乎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

賢者會做到這一點:

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

+0

我看着鼠尾草,源代碼是巨大的,它是否支持python開箱即用?上面的代碼是Python代碼? – user423805 2011-06-16 12:38:17

+0

是的,它非常大:它是一個包含在Python中的數學工具和庫的集合。但是,如果你所做的每件事都是數字化的,並且你不需要符號,那麼直接使用matplotlib可能是最簡單的(畢竟,這就是Sage在後臺執行的操作)。 – DSM 2011-06-16 13:57:27

+1

您可以使用sage網頁,而不安裝它,如果你喜歡:http://www.sagenb.org/ – 2011-06-16 16:53:06

0

這些答案沒有改變使用拖曳工具的參數選項。如果你想要這個選項,那麼這兩個示例動態系統會告訴你如何。它們是用Python Sage編寫的。只要將它看作是具有大量數學預製函數的Python。


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