如何在python中绘制水平时间序列

问题描述 投票:-1回答:1

我有看起来像这样的DataFrame df

    x0  x1    x2   x3   x4   x5   ... x10000   Date     
1    40  31.05 25.5 25.5 25.5 25   ...  33     2006-01-01 
2    35  35.75 36.5 36.5 36.5 36.5 ...  29     2007-01-01 

其中每行是一个具有1分钟常规时间间隔的时间序列。

如何在python中按时间序列绘制所有行的图形?

python pandas matplotlib
1个回答
0
投票

您可以尝试以下方法:

df = pd.DataFrame({ f'x{i}': np.random.randn(10) for i in range(10)})
df['Date'] = pd.date_range(start='1/1/1979', periods=len(df), freq='D')
plt.plot(df.drop('Date', axis=1))
plt.legend(df['Date'], bbox_to_anchor=(1.05, 1), loc='upper left', borderaxespad=0.)
plt.show()
© www.soinside.com 2019 - 2024. All rights reserved.