Pyplot Quiver 函数中的奇怪行为

Strange Behavior in Pyplot Quiver Function

我有一个非常简单的代码单元格,它使用 pyplot.quiver 绘制单个向量。它应该从 (0,0) 开始并延伸到 (1,1)。但是,箭头显然不是指向 (1,1).

文档说,调用签名:

quiver([X, Y], U, V, [C], **kw)

X, Y define the arrow locations, U, V define the arrow directions, and C optionally sets the color.

这里发生了什么?

import numpy as np
import matplotlib.pyplot as plt

plt.quiver(0,0,1,1, scale=5)
plt.xlim(-2, 2)
plt.ylim(-2, 2)
plt.grid()
plt.show()

引用documentation,你应该指定anglesscale_unitsscale参数,以便告诉matplotlib你想引用(x, y)坐标和单位:

ax.quiver(0, 0, 1, 1, angles = 'xy', scale_units = 'xy', scale = 1)