From 78d4a48643caba6ca5d99662548d047534f78964 Mon Sep 17 00:00:00 2001 From: Benedikt Bastin Date: Fri, 15 Jan 2021 19:59:50 +0100 Subject: [PATCH] feat: Added stats to title Added total vaccinations, vaccination percentage and mean daily vaccination rate to title --- plot.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/plot.py b/plot.py index 5783128..a7ae910 100644 --- a/plot.py +++ b/plot.py @@ -46,9 +46,14 @@ dates = impfungen['Datum'] daily = impfungen['Gesamtzahl Impfungen'] cumulative = np.cumsum(impfungen['Gesamtzahl Impfungen']) -mean_vaccinations_daily = np.mean(daily) +total_vaccinations = int(np.sum(daily)) +total_vaccinations_percentage = float(total_vaccinations) / einwohner_deutschland +print(total_vaccinations_percentage) -to_be_vaccinated = einwohner_deutschland - np.sum(daily) +mean_vaccinations_daily = np.mean(daily) +mean_vaccinations_daily_int = int(np.round(mean_vaccinations_daily)) + +to_be_vaccinated = einwohner_deutschland - total_vaccinations days_extrapolated = int(np.ceil(to_be_vaccinated / mean_vaccinations_daily)) extrapolated_dates = np.array([dates[0] + datetime.timedelta(days=i) for i in range(days_extrapolated)]) @@ -56,6 +61,7 @@ extrapolated_dates = np.array([dates[0] + datetime.timedelta(days=i) for i in ra extrapolated_vaccinations = mean_vaccinations_daily * range(days_extrapolated) + # Stand aus Daten auslesen #stand = dates.iloc[-1] #print_stand = stand.isoformat() @@ -78,7 +84,12 @@ def plot_extrapolation_portion(percentage): plt.title( 'Tägliche Impfquote, kumulierte Impfungen und lineare Extrapolation bis {} % der Bevölkerung Deutschlands\n' - 'Erstellung: {}, Datenquelle: RKI, Stand: {}'.format(print_percentage, print_today, print_stand) + 'Erstellung: {}, Datenquelle: RKI, Stand: {}\n' + 'Impfungen gesamt: {} ({} %), Durchschnittliche Impfrate: {} Impfungen/Tag'.format( + print_percentage, + print_today, print_stand, + total_vaccinations, np.round(total_vaccinations_percentage * 100, 2), mean_vaccinations_daily_int + ) ) ax2 = ax.twinx() @@ -89,7 +100,7 @@ def plot_extrapolation_portion(percentage): ax2.set_xlim(xmax=dates[0] + datetime.timedelta(days=percentage * days_extrapolated)) ax2.grid(True) ax2.plot(dates, cumulative, color='red', label='Kumulierte Impfungen') - ax2.plot(extrapolated_dates, extrapolated_vaccinations, color='orange', label='Extrap. kumulierte Impfungen\n({} Impfungen/Tag)'.format(int(np.round(mean_vaccinations_daily)))) + ax2.plot(extrapolated_dates, extrapolated_vaccinations, color='orange', label='Extrap. kumulierte Impfungen\n({} Impfungen/Tag)'.format(mean_vaccinations_daily_int)) #ax2.plot() ax.legend(loc='upper left')