from matplotlib import pyplot as m

m.figure(“max”,facecolor=‘lightgray’)

子图1
m.subplot(2,2,1) #设置2行两列的格式
m.xticks(())
m.yticks(())
m.text(0.5,0.5,‘1’,ha=“center”,va=‘center’,size=36,alpha=0.5)

图2
m.subplot(2,2,2)
m.xticks(())
m.yticks(())
m.text(0.5,0.5,‘2’,ha=“center”,va=‘center’,size=36,alpha=0.5)

图3
m.subplot(2,2,3)
m.xticks(())
m.yticks(())
m.text(0.5,0.5,‘3’,ha=“center”,va=‘center’,size=36,alpha=0.5)
图4
m.subplot(2,2,4)
m.xticks(())
m.yticks(())
m.text(0.5,0.5,‘4’,ha=“center”,va=‘center’,size=36,alpha=0.5)

m.show()

珊格定位图matplotlib 中子图的创建

from matplotlib import pyplot as m ,gridspec as mg

m.figure(“max”,facecolor=‘lightgray’)

gs=mg.GridSpec(3,3)
m.subplot(gs[0,:2])
m.xticks(())
m.yticks(())
m.text(0.5,0.5,‘1’,ha=“center”,va=‘center’,size=36,alpha=0.5)

gs=mg.GridSpec(3,3)
m.subplot(gs[1:3,0])
m.xticks(())
m.yticks(())
m.text(0.5,0.5,‘2’,ha=“center”,va=‘center’,size=36,alpha=0.5)

gs=mg.GridSpec(3,3)
m.subplot(gs[2,1:3])
m.xticks(())
m.yticks(())
m.text(0.5,0.5,‘3’,ha=“center”,va=‘center’,size=36,alpha=0.5)

gs=mg.GridSpec(3,3)
m.subplot(gs[:2,2])
m.xticks(())
m.yticks(())
m.text(0.5,0.5,‘4’,ha=“center”,va=‘center’,size=36,alpha=0.5)

gs=mg.GridSpec(3,3)
m.subplot(gs[1,1])
m.xticks(())
m.yticks(())
m.text(0.5,0.5,‘5’,ha=“center”,va=‘center’,size=36,alpha=0.5)

m.show()

相关文章:

  • 2021-08-20
  • 2021-07-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2022-02-10
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-04
  • 2021-05-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
相关资源
相似解决方案