matplotlib 中子图的创建
作者:互联网
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()
珊格定位图
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()
标签:va,gs,center,创建,0.5,matplotlib,中子,text,size 来源: https://blog.51cto.com/u_15177056/2725507