子时隙/数据帧x轴上的时间序列

2024-04-26 23:23:12 发布

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

我试图从pandas数据帧创建子图,时间在x轴上以hh:mm:ss表示

它在没有子地块的情况下工作,但当我尝试使用2个子地块AttributeError时,出现以下错误:“numpy.ndarray”对象没有属性“set\xticks”

如有任何建议,将不胜感激

ax = df[df.columns[6:8]].plot(figsize=(7,5), grid = True, legend = True, subplots=True, layout = (2,1), sharex = False)

ax[0].set_xticks(df.index[::60].flatten())
ax[0].set_xticklabels(df.Time[::60], rotation=90)

ax[1].set_xticks(df.index[::60].flatten())
ax[1].set_xticklabels(df.Time[::60], rotation=90)
plt.show()

Tags: 数据truepandasdfindextimehh时间