matplotlib.pyplot.quiver
函数接受一组“起点”和一组“终点”,然后绘制一堆箭头,从“起点”处开始,在“终点”的方向上指向。但是,有一个缩放因子,使箭头不一定在“终点”处结束,它们只是朝着那个方向指向。例如:import matplotlib.pyplot as plt
import numpy as np
pts = np.array([[1, 2], [3, 4]])
end_pts = np.array([[2, 4], [6, 8]])
plt.quiver(pts[:,0], pts[:,1], end_pts[:,0], end_pts[:,1])
请注意左下方的向量起点是 (1,2)(这正是我想要的),但它并没有以 (2,4) 结束。这是由于 quiver
函数中的 scale
参数控制箭头的长度。我该如何让箭头恰好结束于 (2,4)?