matplotlib画子图

import numpy as np

fig = plt.figure()

fig = plt.figure(figsize=(3, 3)) #设置图片大小

fig.add_subplot(a,b,c) a行b列的,c代表位置

ax1 = fig.add_subplot(2,1,1) #2行1列的第一个图
ax2 = fig.add_subplot(2,1,2) #2行1列的第二个图

作图

ax1.plot(np.random.randint(1,5,5), np.arange(5),c="red")
ax2.plot(np.arange(10)*3, np.arange(10),c="green")
plt.show()


matplotlib画子图_第1张图片
untitled.png

你可能感兴趣的:(matplotlib画子图)