pandas实现一布多表,一表多线

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()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值