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

时间:2019-11-04 03:12:27

标签: python pandas matplotlib

我有一个看起来像这样的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中按时间序列绘制所有行的图形?

1 个答案:

答案 0 :(得分: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()
相关问题