Q:用plt.subplot()方法 把4个子图在一个figure里可以实现吗
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.font_manager import FontProperties
font = FontProperties(fname="C:\Windows\Fonts\STXINGKA.TTF",size=10)
x=np.arange(1,16)
x_label=['11-02','11-04','11-06','11-08','11-10','11-12','11-14','11-16','11-18','11-20','11-22','11-24','11-26','11-28','11-30']
y1=[531, 596, 535, 1294, 1150, 1675, 1621, 2328, 2055, 2277, 2641, 3041, 3648, 3561, 4080]
y2=[2669, 3063, 4961, 6882, 9385, 13086, 16151, 20804, 22208, 24547, 26242, 29654, 35858, 34860, 31720]
y3=[4641, 5473, 6113, 7801, 9385, 11647, 13935, 16631, 19102, 21550, 23923, 27429, 30646, 33190, 36571 ]
y4=[22423, 26924, 34158, 45493, 59141, 79170, 105362, 136643, 172048, 207376, 245895, 281195, 318626, 360424, 386711]
plt.subplot(2,2,1)
plt.xticks(x,x_label,rotation=60)
plt.title('新增本土确诊',fontproperties=font)
plt.plot(x,y1)
plt.show()
plt.subplot(2,2,2)
plt.xticks(x,x_label,rotation=60)
plt.title('新增本土无症状',fontproperties=font)
plt.plot(x,y2)
plt.show()
plt.subplot(2,2,3)
plt.xticks(x,x_label,rotation=60)
plt.title('现有本土确诊',fontproperties=font)
plt.plot(x,y3)
plt.show()
plt.subplot(2,2,4)
plt.xticks(x,x_label,rotation=60)
plt.title('现有无症状',fontproperties=font)
plt.plot(x,y4)
plt.show()