【发布时间】:2017-12-28 09:19:14
【问题描述】:
我有一个带有 DateTime 索引的 pandas DataFrame。
我可以从中绘制一个时间序列,默认情况下它看起来不错。
但是当我尝试从同一个 DataFrame 打印条形图时,xAxis 标签被破坏(大量重叠)。 (而且数据的间距很奇怪(条组之间的差距很大)
我试过autoformat_xdate(),但没有任何帮助。
这是我用来生成图表的简单代码片段
entire_df['predict'] = regr.predict(entire_df[X_cols])
entire_df['error'] = entire_df['predict']-entire_df['px_usd_mmbtu']
#entire_df['error'].plot(kind='hist')
fig=plt.figure()
entire_df[['px_usd_mmbtu', 'predict']].plot()
fig2 = plt.figure()
entire_df['error'].plot(kind='bar')
#fig2.autofmt_xdate() #doesn't help
print (type(error_df.index))
【问题讨论】:
标签: python pandas datetime matplotlib