2013-02-19 36 views
2

我正在模擬多個變量隨時間變化的模擬。偶爾,繪製變量不是針對時間軸(x(t)相對於t)而是相互相反(x(t)相對於y(t))的變量。 在這些情況下,如果我可以添加某種指示時間流向的箭頭(疊加在曲線上),那將會很好。向matplotlib中的參數圖添加箭頭

我的問題:是否有人知道一個簡單或內置的方法來做到這一點,或者我應該自己一起破解一些東西?

+0

並不想在這裏繪製矢量場。我有一條曲線(更多的是一個循環),它表示模擬期間達到的參數空間中的不同點。我正在尋找的是一種在曲線上疊加幾個箭頭的方式,顯示模擬的方向。 – 2013-02-19 16:55:46

+1

正確 - 我在閱讀您的問題時很倉促。我仍然認爲你可以[與'顫抖'一起劈砍](http://stackoverflow.com/questions/7519467/line-plot-with-arrows-in-matplotlib),繪製你現有的曲線,並使用只說前兩個和/或後兩個點 – YXD 2013-02-19 16:57:00

回答

2

試試這個(從matplotlib食譜http://www.scipy.org/Cookbook/Matplotlib/Arrows):

from pylab import * 
from numarray import * 

x = arange(10) 
y = x 

# Plot junk and then a filled region 
plot(x, y) 

# Now lets make an arrow object 
arr = Arrow(2, 2, 1, 1, edgecolor='white') 

# Get the subplot that we are currently working on 
ax = gca() 

# Now add the arrow 
ax.add_patch(arr) 

# We should be able to make modifications to the arrow. 
# Lets make it green. 
arr.set_facecolor('g') 

enter image description here