我正在进行多个变量随时间变化的模拟。有时,绘制变量时,不是相对于时间轴(x(t) 与 t)而是相对于彼此(x(t) 与 y(t))绘制变量是很有用的。 在这些情况下,如果我可以添加某种箭头(覆盖在曲线上)来指示时间流的方向,那就太好了。
我的问题:有人知道有一个简单的或内置的方法可以做到这一点,还是我应该自己编写一些东西?
最佳答案
试试这个(来自 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')
关于python - 在 matplotlib 中向参数图添加箭头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14962739/