From 8e99015d77febc77ffb9cb55f256293a5b6db5c6 Mon Sep 17 00:00:00 2001 From: Benedikt Bastin Date: Sat, 24 Apr 2021 12:05:52 +0200 Subject: [PATCH] feat: New detail view plot for vaccination done date plot --- plot.py | 58 +++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/plot.py b/plot.py index e027756..3ec908b 100644 --- a/plot.py +++ b/plot.py @@ -757,23 +757,16 @@ def plot_vaccination_done_dates(): ) d = data_first_vaccination - #print(d['cumulative']) - #print(np.sum(d['daily'])) - - #print((einwohner_deutschland - d['cumulative'])[:-1] - d['to_be_vaccinated']) - - days_remaining_daily = np.ceil((einwohner_deutschland * 0.7 - d['cumulative']) / (d['mean_vaccination_rates_daily'])) days_remaining_rolling = np.ceil((einwohner_deutschland * 0.7 - d['cumulative']) / (d['vaccination_rates_daily_rolling_average'])) dates_daily = [today + datetime.timedelta(days) for days in days_remaining_daily] dates_rolling = [today + datetime.timedelta(days) for days in days_remaining_rolling.dropna()] - #print(dates_rolling) - ax.set_xlim(start_of_reporting_date, today) ax.set_ylim(today, today + datetime.timedelta(int(np.max(days_remaining_rolling) * 1.05))) ax.axhline(target_date_for_herd_immunity - datetime.timedelta(21), label='Impfziel Ende Sommer') + ax.add_patch(Rectangle((datetime.date(2021, 4, 6), today), today - datetime.date(2021, 4, 6), target_date_for_herd_immunity - today, edgecolor='darkgrey', lw=3, fill=False, label='Detailansicht (s.u.)')) ax.plot(dates, dates_daily, label='Durchschnitt Gesamt', linewidth=0.5) ax.plot(dates[6:], dates_rolling, label='Durchschnitt 7 Tage', linewidth=2) @@ -793,6 +786,51 @@ def plot_vaccination_done_dates(): plot_vaccination_done_dates() +def plot_vaccination_done_dates_detail(): + + plot_name = 'vaccination_done_dates_detail' + if not check_recreate_plot(plot_name): + return + + fig, ax = plt.subplots(1) + + + plt.title( + 'Lin. Extrapolation der Erstimpfungen bis 70 % der Bevölkerung anhand der durchschn. Impfrate (Detail, Datum, Gesamt und 7 Tage)\n' + 'Datenquelle: RKI, Stand: {}. Erstellung: {}, Ersteller: Benedikt Bastin, Lizenz: CC BY-SA 4.0\n'.format( + print_stand, print_today + ) + ) + d = data_first_vaccination + + days_remaining_daily = np.ceil((einwohner_deutschland * 0.7 - d['cumulative']) / (d['mean_vaccination_rates_daily'])) + days_remaining_rolling = np.ceil((einwohner_deutschland * 0.7 - d['cumulative']) / (d['vaccination_rates_daily_rolling_average'])) + + dates_daily = [today + datetime.timedelta(days) for days in days_remaining_daily] + dates_rolling = [today + datetime.timedelta(days) for days in days_remaining_rolling.dropna()] + + ax.set_xlim(datetime.date(2021, 4, 6), today) + ax.set_ylim(today, target_date_for_herd_immunity) + ax.axhline(target_date_for_herd_immunity - datetime.timedelta(21), label='Impfziel Ende Sommer') + + ax.plot(dates, dates_daily, label='Durchschnitt Gesamt', linewidth=0.5) + ax.plot(dates[6:], dates_rolling, label='Durchschnitt 7 Tage', linewidth=2) + + ax.grid(True) + + + ax.legend(loc='upper right') + + ax.set_xlabel('Datum') + ax.set_ylabel('Datum, an dem 70 % erreicht sind') + + add_annotations(ax) + + save_plot(plot_name) + plt.close() + +plot_vaccination_done_dates_detail() + def render_dashboard(): dashboard_filename = 'site/index.xhtml' dashboard_archive_filename = 'site/archive/{}/index.xhtml'.format(filename_stand) @@ -880,6 +918,10 @@ def render_dashboard(): 'index': 12, 'filename': 'vaccination_done_dates', 'caption': 'Lineare Extrapolation bis 70 % der Bevölkerung anhand der Erstimpfungen der durchschnittlichen Impfrate (Datum, Gesamt und 7 Tage)' + },{ + 'index': 13, + 'filename': 'vaccination_done_dates_detail', + 'caption': 'Lineare Extrapolation bis 70 % der Bevölkerung anhand der Erstimpfungen der durchschnittlichen Impfrate (Datum, Gesamt und 7 Tage)' } ] ).dump('site/index.xhtml')