14Subplot分格显示

import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec

#method 1
plt.figure()
ax1 = plt.subplot2grid((3,3),(0,0),colspan=3,rowspan=1)
ax1.plot([1,2],[1,2])
ax1.set_title('ax1_title')
ax2=plt.subplot2grid((3,3),(1,0),colspan=2)
ax3=plt.subplot2grid((3,3),(1,2),rowspan=2)
ax4=plt.subplot2grid((3,3),(2,0))
ax5=plt.subplot2grid((3,3),(2,1))

#method 2
plt.figure()
gs = gridspec.GridSpec(3,3)
ax11 = plt.subplot(gs[0,:])
ax12 = plt.subplot(gs[1,:2])
ax13 = plt.subplot(gs[1:,2])
ax14 = plt.subplot(gs[-1,0])
ax15 = plt.subplot(gs[-1,-2])




plt.show()

image-20230131185801756

image-20230131185811983

posted @   不迷路的小孩  阅读(30)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术
点击右上角即可分享
微信分享提示