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

2024-03-28 09:57:05 发布

您现在位置:Python中文网/ 问答频道 /正文

数据帧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中将所有行的图形都绘制为时间序列?你知道吗


Tags: 数据图形dfdate间隔时间序列中将
1条回答
网友
1楼 · 发布于 2024-03-28 09:57:05

你可以试试这个:

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()

相关问题 更多 >