2013-02-19 82 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