subplot的使用

 1 import matplotlib.pyplot as plt 
 2 import numpy as np 
 3 #将画布分区,指定区域作图
 4 x = np.linspace(1,10,100)
 5 #将画布分为2x2
 6 plt.subplot(2,2,1)
 7 #修改x,y轴的坐标
 8 plt.xlim(-5,20)
 9 plt.ylim(-2,2)
10 plt.plot(x,np.sin(x))
11 plt.subplot(2,2,4)
12 plt.plot(x,np.cos(x))
13 plt.show()

猜你喜欢

转载自www.cnblogs.com/monsterhy123/p/12642426.html
今日推荐