下面是我的数据框,其中有很多行,因此我试图将x轴标签以及条形图和线图一起整理。
time, Actual, Predicted
2018-11-02 12:00:00,38.221491228070185,74.16629033284582
2018-11-02 13:00:00,42.16867469879517,53.64663362397784
2018-11-02 17:00:00,82.34042553191486,62.01304856981184
下面是代码段。上面的csv文件被读入“ fth”数据帧
def plotValues():
pyplot.subplot(211)
pyplot.grid(True)
pyplot.ylabel('Values')
pyplot.gcf().autofmt_xdate()
df.plot(ax=pyplot.gca(),legend=None)
pyplot.subplot(212)
pyplot.grid(True)
pyplot.ylabel('Litres')
pyplot.gca().xaxis.set_minor_locator(dates.HourLocator(interval=12))
pyplot.gcf().autofmt_xdate()
pyplot.tight_layout()
ax1 = fth[['Actual']].plot(ax=pyplot.gca(),kind='bar')
fth[['Predicted']].plot(ax=ax1,color="red")