matplotlib中在for中画出多张图
import matplotlib.pyplot as plt import numpy as np fig, axes = plt.subplots(2, 2) def showim(): for i in range(2): for j in range(2): axes[i,j].plot(np.random.randint(10,size=10)) # 为每个子图添加标题 axes[i,j].set_title("picture "+str(i)+" "+str(j)) fig.tight_layout() # 为每个子图去掉坐标轴刻度 axes[i,j].set_xticks([]) axes[i,j].set_yticks([]) showim() plt.show()