Exemplo n.º 1
0
color_bed = ['red', 'black']  # 0 感染者入住 , 1空床位

fig = plt.figure(figsize=(20, 10))

plt.style.use('dark_background')
fig.patch.set_facecolor('black')

gs = plt.GridSpec(3, 5, wspace=0.5, hspace=0.5)
ax1 = plt.subplot(gs[:, 0:3])
ax2 = plt.subplot(gs[:, 3])
ax3 = plt.subplot(gs[0, 4])
ax4 = plt.subplot(gs[1, 4])
ax5 = plt.subplot(gs[2, 4])

Hx = hospital.getX()
Hy = hospital.getY()

# 只更新动态对象,而静态对象保存起来
ax1background = fig.canvas.copy_from_bbox(ax1.bbox)
ax2background = fig.canvas.copy_from_bbox(ax2.bbox)


def animate(time):
    status_of_pool = pool.getStatus()
    status_of_hospital = hospital.getStatus()  # 空 = true 1 black
    # print(status_of_hospital)
    healthy = np.sum(status_of_pool == 0)
    infected = np.sum(status_of_pool == 1)
    confirmed = np.sum(status_of_pool == 2)
    hospitalized = np.sum(status_of_hospital == False)
    # print(hospitalized)