Python 如何绘制时间序列的倒数
我有一个timeseries,看起来像这样:Python 如何绘制时间序列的倒数,python,numpy,matplotlib,time-series,Python,Numpy,Matplotlib,Time Series,我有一个timeseries,看起来像这样: import matplotlib.pyplot as plt import numpy as np data = [ 0.0320312479743734, 0.029813902801834047, 0.029573831125162542, 0.018995469145011157, 0.027841876726597548, 0.04128658
import matplotlib.pyplot as plt
import numpy as np
data = [
0.0320312479743734,
0.029813902801834047,
0.029573831125162542,
0.018995469145011157,
0.027841876726597548,
0.041286583291366696,
0.04001532797701657,
0.036066913162358105,
0.05553811206482351,
0.019244458235334605,
0.0350094516761601,
0.025880977045744658,
0.00444492106908001,
0.021624276996590197,
0.024681835202500224,
0.020811115973629057,
0.022745881869923323,
0.03943057672586292,
0.025860359892249107,
0.020410736033227295
]
plt.plot(data)
在python中,如何创建这条直线的倒数并绘制它?反向,我的意思是这样的(请忽略y轴,它应该与第一个相同,但我只是垂直翻转图像进行演示):
我并不是说画出与绝对距离相反的直线,比如:
import matplotlib.pyplot as plt
import numpy as np
data = [
0.0320312479743734,
0.029813902801834047,
0.029573831125162542,
0.018995469145011157,
0.027841876726597548,
0.041286583291366696,
0.04001532797701657,
0.036066913162358105,
0.05553811206482351,
0.019244458235334605,
0.0350094516761601,
0.025880977045744658,
0.00444492106908001,
0.021624276996590197,
0.024681835202500224,
0.020811115973629057,
0.022745881869923323,
0.03943057672586292,
0.025860359892249107,
0.020410736033227295
]
plt.plot(data)
不确定是否有一个漂亮的
numpy
函数用于此功能,但您可以执行以下操作:
inverse = np.array(data)
inverse = inverse.max() - (inverse - inverse.min())
plt.plot(inverse)
在原始数据上:
不确定是否有一个漂亮的
numpy
函数用于此功能,但您可以执行以下操作:
inverse = np.array(data)
inverse = inverse.max() - (inverse - inverse.min())
plt.plot(inverse)
在原始数据上: