这是一个起点:
>沿着你的行走在固定的步骤(在我的例子下面的aspace).
A.这涉及沿着由两组点(x1,y1)和(x2,y2)创建的线段进行步骤.
B.如果您的步长比线段长,则切换到下一组点.
>此时确定线的角度.
>绘制一个与角度对应的倾斜的箭头.
我写了一个小脚本来证明这一点:
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
axes = fig.add_subplot(111)
# my random data
scale = 10
np.random.seed(101)
x = np.random.random(10)*scale
y = np.random.random(10)*scale
# spacing of arrows
aspace = .1 # good value for scale of 1
aspace *= scale
# r is the distance spanned between pairs of points
r = [0]
for i in range(1,len(x)):
dx = x[i]-x[i-1]
dy = y[i]-y[i-1]
r.append(np.sqrt(dx*dx+dy*dy))
r = np.array(r)
# rtot is a cumulative sum of r, it's used to save time