【问题标题】:how to calculate phase space of velocity and draw a scatter plot in python?如何计算速度的相空间并在python中绘制散点图?
【发布时间】:2019-11-24 02:07:22
【问题描述】:

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

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

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

【问题讨论】:

标签: python python-3.x matplotlib


【解决方案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()

【讨论】:

    【解决方案2】:

    假设Δ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()
    

    【讨论】:

      猜你喜欢
      • 2017-07-21
      • 2011-05-07
      • 2020-07-28
      • 2020-09-24
      • 2019-08-03
      • 2020-09-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多