How to draw multiple pictures on the same page? Mainly used is the subplot function in the matplotlib library.
Attached code:
import seaborn
import numpy
import matplotlib.pyplot as plt
dist_data_1=numpy.random.normal(25,10,500).astype(int)
dist_data_2=numpy.random.normal(30,10,500).astype(int)
fig,axes=plt.subplots(2,2)
#生成2*2的画布
plt.subplot(2,2,1)
#画布中的第一张图
seaborn.distplot(dist_data_1,ax=axes[0][0])
plt.subplot(2,2,2)
seaborn.distplot(dist_data_2,ax=axes[0][1])
plt.subplot(2,2,3)
seaborn.distplot(dist_data_1,ax=axes[1][0])
plt.subplot(2,2,4)
seaborn.distplot(dist_data_2,ax=axes[1][1])
plt.show()
The final result is as follows:
If you want to draw two 1*2 pictures, change axes[][] to axes[]