av6989413
一张图内生成多个子图
x=np.arange(1,100)
fig=plt.figure()
#参数分别为:子图总行数,子图总列数,子图位置
ax1 = fig.add_subplot(221)
ax1.plot(x,x)
ax2 = fig.add_subplot(222)
ax2.plot(x,-x)
plt.show()
也可以直接使用plt.subplot(221)
plt.plot(x,x)画出子图
生成多张图
#多图
fig1=plt.figure()
ax1=fig1.add_subplot(111)
ax1.plot([1,2,3],[3,2,1])
fig2=plt.figure()
ax2=fig2.add_subplot(111)
ax2.plot([1,2,1],[1,2,3])
plt.show()
网格
plt.grid(True)
图例
x = np.arange(1,11,1)
p