如何计算速度的相空间并在python中绘制散点图?

时间:2019-07-15 11:17:09

标签: python python-3.x matplotlib

我有一个时间序列速度的矢量。例如:

u=[100,120,150,115,130,115,105,103,108,132,135,121]

现在我需要计算Δu,然后绘制一个散点图。 如下图所示。 我该怎么办?

enter image description here

2 个答案:

答案 0 :(得分:1)

import numpy as np
import matplotlib.pyplot as plt

u = np.array([100,120,150,115,130,115,105,103,108,132,135,121])
du = u[1:] - u[:-1] # the difference between the current and the prior velocity

plt.scatter(u[1:],du)
plt.show()

答案 1 :(得分:0)

假设Δu = u[i] - u[i-1],显然您应该对u[1:]使用此公式。 因此,只需使用以下代码行:

from numpy import array
import matplotlib.pyplot as plt

u = aray(u)
del_u = u[1:] - u[:-1] # This line let you use that formula for all numbers in array except first one.
plt.scatter(u[1:], del_u)
plt.show()