瀏覽代碼

update pics display

master
杨浩然 4 年之前
父節點
當前提交
93e4065431
共有 2 個檔案被更改,包括 61 行新增13 行删除
  1. 二進制
      COVID-19/Project/.vs/Project/v16/.suo
  2. +61
    -13
      COVID-19/Project/Project/Project.py

二進制
COVID-19/Project/.vs/Project/v16/.suo 查看文件


+ 61
- 13
COVID-19/Project/Project/Project.py 查看文件

@ -5,7 +5,7 @@ import numpy as np
import datetime
import math
from scipy import interpolate
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
#打开数据文件
@ -20,10 +20,11 @@ dataset = dataset.fillna(0)
dataset['Date'] = pd.to_datetime(dataset['Date'])
#对China数据进行可视化操作
China = dataset[dataset['Country/Region'] == 'China'].reset_index(drop=True)
#对China\US数据进行可视化操作
China = dataset[dataset['Country/Region'] == 'China'].reset_index(drop=True)
US = dataset[dataset['Country/Region'] == 'US'].reset_index(drop=True)
#计算每日治愈率/确诊人数/治愈人数(分月份显示)
#计算中\美每日治愈率/确诊人数/治愈人数(分月份显示)
dfChinaJan = China[China['Date'].dt.month == 1]
dfChinaFeb = China[China['Date'].dt.month == 2]
dfChinaMar = China[China['Date'].dt.month == 3]
@ -37,21 +38,68 @@ dfChinaOct = China[China['Date'].dt.month == 10]
dfChinaNov = China[China['Date'].dt.month == 11]
dfChinaDec = China[China['Date'].dt.month == 12]
confirmed = [dfChinaJan['Confirmed'].sum(),dfChinaFeb['Confirmed'].sum(),dfChinaMar['Confirmed'].sum(),dfChinaApr['Confirmed'].sum(),
dfUSJan = US[US['Date'].dt.month == 1]
dfUSFeb = US[US['Date'].dt.month == 2]
dfUSMar = US[US['Date'].dt.month == 3]
dfUSApr = US[US['Date'].dt.month == 4]
dfUSMay = US[US['Date'].dt.month == 5]
dfUSJun = US[US['Date'].dt.month == 6]
dfUSJul = US[US['Date'].dt.month == 7]
dfUSAug = US[US['Date'].dt.month == 8]
dfUSSept = US[US['Date'].dt.month == 9]
dfUSOct = US[US['Date'].dt.month == 10]
dfUSNov = US[US['Date'].dt.month == 11]
dfUSDec = US[US['Date'].dt.month == 12]
confirmedChina = [dfChinaJan['Confirmed'].sum(),dfChinaFeb['Confirmed'].sum(),dfChinaMar['Confirmed'].sum(),dfChinaApr['Confirmed'].sum(),
dfChinaMay['Confirmed'].sum(),dfChinaJun['Confirmed'].sum(),dfChinaJul['Confirmed'].sum(),dfChinaAug['Confirmed'].sum(),
dfChinaSept['Confirmed'].sum(),dfChinaOct['Confirmed'].sum(),dfChinaNov['Confirmed'].sum(),dfChinaDec['Confirmed'].sum()]
recovered = [dfChinaJan['Recovered'].sum(),dfChinaFeb['Recovered'].sum(),dfChinaMar['Recovered'].sum(),dfChinaApr['Recovered'].sum(),
recoveredChina = [dfChinaJan['Recovered'].sum(),dfChinaFeb['Recovered'].sum(),dfChinaMar['Recovered'].sum(),dfChinaApr['Recovered'].sum(),
dfChinaMay['Recovered'].sum(),dfChinaJun['Recovered'].sum(),dfChinaJul['Recovered'].sum(),dfChinaAug['Recovered'].sum(),
dfChinaSept['Recovered'].sum(),dfChinaOct['Recovered'].sum(),dfChinaNov['Recovered'].sum(),dfChinaDec['Recovered'].sum()]
recoverPoss = []
for i in range(len(confirmed)):
recoverPoss.append(recovered[i] / confirmed[i])
date = pd.date_range(start='2020-01', periods=12, freq="m").strftime('%Y-%m')
recoverPossChina = []
confirmedUS = [dfUSJan['Confirmed'].sum(),dfUSFeb['Confirmed'].sum(),dfUSMar['Confirmed'].sum(),dfUSApr['Confirmed'].sum(),
dfUSMay['Confirmed'].sum(),dfUSJun['Confirmed'].sum(),dfUSJul['Confirmed'].sum(),dfUSAug['Confirmed'].sum(),
dfUSSept['Confirmed'].sum(),dfUSOct['Confirmed'].sum(),dfUSNov['Confirmed'].sum(),dfUSDec['Confirmed'].sum()]
recoveredUS = [dfUSJan['Recovered'].sum(),dfUSFeb['Recovered'].sum(),dfUSMar['Recovered'].sum(),dfUSApr['Recovered'].sum(),
dfUSMay['Recovered'].sum(),dfUSJun['Recovered'].sum(),dfUSJul['Recovered'].sum(),dfUSAug['Recovered'].sum(),
dfUSSept['Recovered'].sum(),dfUSOct['Recovered'].sum(),dfUSNov['Recovered'].sum(),dfUSDec['Recovered'].sum()]
recoverPossUS = []
for i in range(len(confirmedChina)):
recoverPossChina.append(recoveredChina[i] / confirmedChina[i])
recoverPossUS.append(recoveredUS[i] / confirmedUS[i])
#x轴为日期(月份)
date = pd.date_range(start='2020-01', periods=12, freq="m").strftime('%m')
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.plot(date,confirmed,recovered)
#中国
ax1 = fig.add_subplot(221)
ax1.set_title("Recovered/Confirmed/Recovery Possibility(month) of China",verticalalignment="bottom",fontsize="13")
data1 = ax1.plot(date,confirmedChina,color="red",linewidth="1.7",label="confirmed")
data2 = ax1.plot(date,recoveredChina,color="lime",linewidth="1.7",label="recovered")
ax1.set_ylabel('recovered/confirmed')
ax2 = ax1.twinx()
ax2.plot(date,recoverPoss)
ax2.set_ylabel('recovery possibility')
data3 = ax2.plot(date,recoverPossChina,color="blue",linestyle="--",linewidth="1.0",label="recovery possibility")
datasChina = data1 + data2 + data3
labsChina = [d.get_label() for d in datasChina]
ax1.legend(datasChina, labsChina, loc="lower right")
#美国
ax3 = fig.add_subplot(223)
ax3.set_title("Recovered/Confirmed/Recovery Possibility(month) of US",verticalalignment="bottom",fontsize="13")
data3 = ax3.plot(date,confirmedUS,color="red",linewidth="1.7",label="confirmed")
data4 = ax3.plot(date,recoveredUS,color="lime",linewidth="1.7",label="recovered")
ax3.set_ylabel('recovered/confirmed')
ax4 = ax3.twinx()
ax4.set_ylabel('recovery possibility')
data5 = ax4.plot(date,recoverPossUS,color="blue",linestyle="--",linewidth="1.0",label="recovery possibility")
datasUS = data3 + data4 + data5
labsUS = [d.get_label() for d in datasUS]
ax3.legend(datasUS, labsUS, loc="upper left")
plt.show()

Loading…
取消
儲存