@interact
def plot_by_country(country = countries):
#
l1 = 'Infected at ' + last_date + ' - ' + str(confirmed.loc[confirmed['Country/Region'] == country,:].sum()[-1])
l2 = 'Recovered at ' + last_date + ' - ' + str(recovered.loc[recovered['Country/Region'] == country,:].sum()[-1])
l3 = 'Dead at ' + last_date + ' - ' + str(deaths.loc[deaths['Country/Region'] == country,:].sum()[-1])
#
df = pd.DataFrame(confirmed_daily.loc[confirmed_daily['Country/Region'] == country,:].sum()[4:])
df.columns = ['confirmed_daily']
df['recovered_daily'] = recovered_daily.loc[recovered_daily['Country/Region'] == country,:].sum()[4:]
df['deaths_daily'] = deaths_daily.loc[deaths_daily['Country/Region'] == country,:].sum()[4:]
df['deaths_daily'] = deaths_daily.loc[deaths_daily['Country/Region'] == country,:].sum()[4:]
df['smooth_conf_daily'] = smooth_conf_daily.loc[smooth_conf_daily['Country/Region'] == country,:].sum()[4:]
#
fig, ax = plt.subplots(figsize = [16,6], nrows = 1)
plt.title('COVID-19 dinamics daily in ' + country)
# ,
ax.bar(df.index, df.confirmed_daily, alpha = 0.5, color = 'orange', label = l1)
ax.bar(df.index, df.recovered_daily, alpha = 0.6, color = 'green', label = l2)
ax.bar(df.index, df.deaths_daily, alpha = 0.7, color = 'red', label = l3)
ax.plot(df.index, df.smooth_conf_daily, alpha = 0.7, color = 'black')
# .
start_date = confirmed_top[confirmed_top.index == country].start_date.iloc[0]
start_point = smooth_conf_daily.loc[smooth_conf_daily['Country/Region'] == country, start_date].sum()
ax.plot_date(start_date, start_point, 'o', alpha = 0.7, color = 'black')
shift = confirmed_top.loc[confirmed_top.index == country, 'trend_max'].iloc[0]/40
plt.text(start_date, start_point + shift, 'Start at ' + start_date, ha ='right', fontsize = 20)
peak_date = confirmed_top[confirmed_top.index == country].peak_date.iloc[0]
peak_point = smooth_conf_daily.loc[smooth_conf_daily['Country/Region'] == country, peak_date].sum()
ax.plot_date(peak_date, peak_point, 'o', alpha = 0.7, color = 'black')
plt.text(peak_date, peak_point + shift, 'Peak at ' + peak_date, ha ='right', fontsize = 20)
ax.xaxis.grid(False)
ax.yaxis.grid(False)
ax.tick_params(axis = 'x', labelrotation = 90)
ax.legend(loc = 'upper left', prop=dict(size=12))
# .
max_pos = max(df['confirmed_daily'].max(), df['recovered_daily'].max())
if confirmed_top[confirmed_top.index == country].peak_passed.iloc[0]:
estimation = 'peak is passed - end of infection ' + confirmed_top[confirmed_top.index == country].end_date.iloc[0]
else:
estimation = 'peak is not passed - end of infection is not clear'
plt.text(df.index[len(df.index)//2], 3*max_pos//4, country, ha ='center', fontsize = 50)
plt.text(df.index[len(df.index)//2], 2*max_pos//3, estimation, ha ='center', fontsize = 20)
#plt.savefig(country + '.png', bbox_inches='tight', dpi = 75)
plt.show()