import matplotlib.pyplot as plt
from pandas import Series
data = Series([1.47,1.62,1.78,1.94,2.38,2.60],index=[‘2012’,‘2013’,‘2014’,‘2015’,‘2016’,‘2017’])
#实例化fig1对象
fig2=plt.figure(figsize=(8,8),facecolor=‘w’)
#实例化ax对象
ax4 = fig2.add_subplot(2,2,1)
ax5 = fig2.add_subplot(2,2,2)
ax6 = fig2.add_subplot(2,1,2)
#用pandas绘图并将图像回传给ax对象
#画ax4
data.plot(kind=‘line’,ax=ax4)#注意对象名是data,它是Pandas中的Series对象类型
data.plot(kind=‘bar’,ax=ax4)
ax4.set_title(‘line chart’)
ax4.set_xlabel(‘Year’)
ax4.set_ylabel(‘Income’)
#画ax5
data.plot(kind=‘box’,ax=ax5)
ax5.set_xticks([])
ax5.set_title(‘box plot’)
ax5.set_xlabel(‘2012~2017’)
ax5.set_ylabel(‘Income’)
#画ax6
data.plot(kind=‘bar’,ax=ax6)
ax6.set_title(‘bar chart’)
ax6.set_xlabel(‘Year’)
ax6.set_ylabel(‘Income’)
#设置fig2标题
fig2.suptitle(‘Using Pandas’)
plt.show()