python - 在 matplotlib 中向参数图添加箭头

标签 python matplotlib

我正在进行多个变量随时间变化的模拟。有时,绘制变量时,不是相对于时间轴(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')

enter image description here

关于python - 在 matplotlib 中向参数图添加箭头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14962739/

相关文章:

python - 使用散点图根据变量绘制没有填充、颜色和大小的圆

python - 类型错误 : an integer is required python

python - 通过键列表访问嵌套字典项?

python - 将图例中的 Matplotlib 矩形更改为圆形

python - 用于从 Matplotlib 绘图的标准 ASCII 文件格式

python - 如何改变x轴在对数刻度中从较大值开始到最小?

python - Matplotlib 得到干净的图(去除所有装饰)

python - py2exe生成dll?

Python 模拟 C++ 指向类成员的指针

python - Pandas .rolling 指定时间窗口和 win_type