第五章 子图的绘制及坐标轴共享

第五章 子图的绘制及坐标轴共享

这节课主要学习了对子图的相关内容进行介绍,首先学习了子图的绘制,包括绘制固定区域和绘制自定义区域的子图;接下来学习了子图坐标轴的共享,最后学习了子图的布局。
接下来是课堂上练习的一些列子:

import matplotlib.pyplot as plt
ax_one=plt.subplot(326)
ax_one.plot([1,2,3,4,5])
ax_two=plt.subplot(312)
ax_two.plot([1,2,3,4,5])
plt.title("2020080603048")
plt.show()

在这里插入图片描述

import numpy as np 
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei']
x=[x for x in range(1,13)]
y1=[20,28,23,16,29,36,39,33,31,19,21,25]
y2=[17,22,39,26,35,23,25,27,29,38,28,20]
labels=['1月','2月','3月','4月','5月','6月','7月','8月',
        '9月','10月','11月','12月']
ax1=plt.subplot(211)
ax1.plot(x,y1,'m--o',lw=2,ms=5,label='产品A')
ax1.plot(x,y2,'g--o',lw=2,ms=5,label='产品B')
ax1.set_title("2020080603048产品A与产品B的销售额趋势",fontsize=11)
ax1.set_ylim(10,45)
ax1.set_ylabel('销售额(亿元)')
ax1.set_xlabel('月份')
for xy1 in zip(x,y1):
    ax1.annotate("%s"% xy1[1],xy=xy1,xytext=(-5,5),
                textcoords='offset points')
for xy2 in zip(x,y2):
    ax1.annotate("%s"% xy2[1],xy=xy2,xytext=(-5,5),
            textcoords='offset points')
ax1.legend()
ax2=plt.subplot(223)
ax2.pie(y1,radius=1,wedgeprops={
   'width':0.5},labels=labels,
       autopct='%3.lf%%',pctdistance=0.75)
ax2.set_title('2020080603048产品A的销售额')
ax3=plt.subplot(224)
ax3.pie(y2,radius=1,wedgeprops={
   'width':0.5},labels=labels,
       autopct='%3.lf%%',pctdistance=0.75)
ax3.set_title('2020080603048产品B的销售额')
plt.tight_layout()
plt.show()

在这里插入图片描述

import matplotlib.pyplot as plt
fig,ax_arr=plt.subplots(2,2)
ax_thr=ax_arr[1,0]
ax_thr.plot([1,2,3,4,5])
plt.title<
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值