|
@ -90,7 +90,7 @@ labsChina = [d.get_label() for d in datasChina] |
|
|
ax1.legend(datasChina, labsChina, loc="lower right") |
|
|
ax1.legend(datasChina, labsChina, loc="lower right") |
|
|
|
|
|
|
|
|
#美国 |
|
|
#美国 |
|
|
ax3 = fig.add_subplot(223) |
|
|
|
|
|
|
|
|
ax3 = fig.add_subplot(222) |
|
|
ax3.set_title("Recovered/Confirmed/Recovery Possibility(month) of US",verticalalignment="bottom",fontsize="13") |
|
|
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") |
|
|
data3 = ax3.plot(date,confirmedUS,color="red",linewidth="1.7",label="confirmed") |
|
|
data4 = ax3.plot(date,recoveredUS,color="lime",linewidth="1.7",label="recovered") |
|
|
data4 = ax3.plot(date,recoveredUS,color="lime",linewidth="1.7",label="recovered") |
|
@ -102,4 +102,36 @@ datasUS = data3 + data4 + data5 |
|
|
labsUS = [d.get_label() for d in datasUS] |
|
|
labsUS = [d.get_label() for d in datasUS] |
|
|
ax3.legend(datasUS, labsUS, loc="upper left") |
|
|
ax3.legend(datasUS, labsUS, loc="upper left") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dataNew = pd.melt(China[['Date','Province/State','Confirmed','Recovered','Deaths']], |
|
|
|
|
|
id_vars=['Date','Province/State'],value_vars=['Confirmed','Recovered','Deaths'], |
|
|
|
|
|
var_name='group_var',value_name='Cases') |
|
|
|
|
|
dataNew['Date'] = pd.to_datetime(dataNew['Date']) |
|
|
|
|
|
dfNew = China[['Province/State','Confirmed','Recovered','Deaths']].groupby(['Province/State']).sum().reset_index() |
|
|
|
|
|
dataNew = pd.melt(dfNew,id_vars=['Province/State'], |
|
|
|
|
|
value_vars=['Confirmed','Deaths','Recovered'], |
|
|
|
|
|
var_name='group_var',value_name='Cases') |
|
|
|
|
|
dataNew = dataNew.sort_values(by=['Province/State','group_var']).reset_index(drop=True) |
|
|
|
|
|
dataNew = dataNew.pivot_table(index=['Province/State'], columns='group_var') |
|
|
|
|
|
dataNew.columns = dataNew.columns.droplevel().rename(None) |
|
|
|
|
|
|
|
|
|
|
|
#中国各省份 |
|
|
|
|
|
dataNew.sort_values('Confirmed', inplace=True) |
|
|
|
|
|
xData = [] |
|
|
|
|
|
yConfirmed = [] |
|
|
|
|
|
yRecovered = [] |
|
|
|
|
|
for i in range(12): |
|
|
|
|
|
xData.append(dataNew.index[i]) |
|
|
|
|
|
yConfirmed.append(dataNew['Confirmed'][i]) |
|
|
|
|
|
yRecovered.append(dataNew['Recovered'][i]) |
|
|
|
|
|
|
|
|
|
|
|
ax5 = fig.add_subplot(212) |
|
|
|
|
|
ax5.set_title("Total Recovered/Confirmed of China(the bottom ten)",verticalalignment="bottom",fontsize="13") |
|
|
|
|
|
barWidth = 0.25 |
|
|
|
|
|
r1 = np.arange(12) |
|
|
|
|
|
r2 = [x + barWidth for x in r1] |
|
|
|
|
|
ax5.bar(r1, yConfirmed, color='#FF0088', width=barWidth, edgecolor='white', label='Confirmed') |
|
|
|
|
|
ax5.bar(r2, yRecovered, color='#00BBFF', width=barWidth, edgecolor='white', label='Recovered') |
|
|
|
|
|
plt.xticks([r + barWidth for r in range(len(yConfirmed))], xData) |
|
|
|
|
|
ax5.legend() |
|
|
plt.show() |
|
|
plt.show() |