From d0807909958069ba1d106b004766f8c0ed4ec1e3 Mon Sep 17 00:00:00 2001 From: Benedikt Bastin Date: Sun, 31 Jan 2021 21:56:34 +0100 Subject: [PATCH 1/3] feat: Added new bar plot comparing both vaccination rates day aligned --- dashboard_template.xhtml | 13 ++++++++++ plot.py | 53 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/dashboard_template.xhtml b/dashboard_template.xhtml index ffc632d..ad46826 100644 --- a/dashboard_template.xhtml +++ b/dashboard_template.xhtml @@ -209,6 +209,19 @@ Download als PDF +
+ + + +
+ Abbildung 4: + Tägliche Impfrate (Erst- und Zweitimpfung nebeneinander)
+ Download als PNG + Download als PDF +
+
diff --git a/plot.py b/plot.py index f9b7a44..b6df546 100644 --- a/plot.py +++ b/plot.py @@ -369,9 +369,9 @@ def plot_vaccination_bar_graph_total_time_two_bars(): archive_plot_filename = '{}/vaccination_bar_graph_total_time_two_bars'.format(archive_folder) latest_plot_filename = '{}/vaccination_bar_graph_total_time_two_bars'.format(site_folder) - #if os.path.isfile(archive_plot_filename + '.pdf'): - #print('Plot {} already exists'.format(archive_plot_filename)) - #return + if os.path.isfile(archive_plot_filename + '.pdf'): + print('Plot {} already exists'.format(archive_plot_filename)) + return fig, ax = plt.subplots(1) @@ -410,6 +410,53 @@ def plot_vaccination_bar_graph_total_time_two_bars(): plot_vaccination_bar_graph_total_time_two_bars() +def plot_vaccination_bar_graph_compare_both_vaccinations(): + + archive_plot_filename = '{}/vaccination_bar_graph_compare_both_vaccinations'.format(archive_folder) + latest_plot_filename = '{}/vaccination_bar_graph_compare_both_vaccinations'.format(site_folder) + + if os.path.isfile(archive_plot_filename + '.pdf'): + print('Plot {} already exists'.format(archive_plot_filename)) + return + + fig, ax = plt.subplots(1) + + + plt.title( + 'Tägliche Impfrate (Erst- und Zweitimpfung um 21 Tage versetzt)\n' + 'Datenquelle: RKI, Stand: {}. Erstellung: {}, Ersteller: Benedikt Bastin, Lizenz: CC BY-SA 4.0\n'.format( + print_stand, print_today + ) + ) + + ax.grid() + + date_numbers_first = date2num(dates + datetime.timedelta(days=21)) + date_numbers_second = date2num(dates) + + ax.bar(date_numbers_first - 0.2, data_first_vaccination['daily'], width=0.4, label='Tägliche Erstimpfungen', color='blue') + ax.bar(date_numbers_second + 0.2, data_second_vaccination['daily'], width=0.4, label='Tägliche Zweitimpfungen', color='lightblue') + + ax.set_ylim([0, np.max([np.max(data_first_vaccination['daily']), np.max(data_second_vaccination['daily'])])]) + + ax.legend(loc='upper left') + ax.xaxis_date() + ax.get_yaxis().get_major_formatter().set_scientific(False) + + ax.set_xlabel('Datum') + ax.set_ylabel('Tägliche Impfungen') + + + plt.savefig(archive_plot_filename + '.pdf') + plt.savefig(archive_plot_filename + '.png') + plt.savefig(latest_plot_filename + '.pdf') + plt.savefig(latest_plot_filename + '.png') + plt.close() + + print('Created plot {} as pdf and png'.format(archive_plot_filename)) + +plot_vaccination_bar_graph_compare_both_vaccinations() + def render_dashboard(): dashboard_filename = 'site/index.xhtml' dashboard_archive_filename = 'site/archive/{}/index.xhtml'.format(filename_stand) From 252afdd5bcc3d4a1f8e0a16b529ab3a755b2f9a3 Mon Sep 17 00:00:00 2001 From: Benedikt Bastin Date: Sun, 31 Jan 2021 21:57:10 +0100 Subject: [PATCH 2/3] fix: Fixed figure numbers --- dashboard_template.xhtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dashboard_template.xhtml b/dashboard_template.xhtml index ad46826..22f95f2 100644 --- a/dashboard_template.xhtml +++ b/dashboard_template.xhtml @@ -203,7 +203,7 @@ alt="" />
- Abbildung 4: + Abbildung 5: Tägliche Impfrate (Erst- und Zweitimpfung nebeneinander)
Download als PNG Download als PDF @@ -216,7 +216,7 @@ alt="" />
- Abbildung 4: + Abbildung 6: Tägliche Impfrate (Erst- und Zweitimpfung nebeneinander)
Download als PNG Download als PDF From af0c17ecf8334ca6d4e3e0082d53ded05fdf15a3 Mon Sep 17 00:00:00 2001 From: Benedikt Bastin Date: Sun, 31 Jan 2021 22:12:03 +0100 Subject: [PATCH 3/3] feat: Added plot for cumulative vaccinations --- dashboard_template.xhtml | 13 +++++++++++ plot.py | 47 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/dashboard_template.xhtml b/dashboard_template.xhtml index 22f95f2..bb917a4 100644 --- a/dashboard_template.xhtml +++ b/dashboard_template.xhtml @@ -222,6 +222,19 @@ Download als PDF
+
+ + + +
+ Abbildung 6: + Tägliche Impfrate (Erst- und Zweitimpfung nebeneinander)
+ Download als PNG + Download als PDF +
+
diff --git a/plot.py b/plot.py index b6df546..d7755b6 100644 --- a/plot.py +++ b/plot.py @@ -457,6 +457,53 @@ def plot_vaccination_bar_graph_compare_both_vaccinations(): plot_vaccination_bar_graph_compare_both_vaccinations() +def plot_cumulative_two_vaccinations(): + archive_plot_filename = '{}/cumulative_two_vaccinations'.format(archive_folder) + latest_plot_filename = '{}/cumulative_two_vaccinations'.format(site_folder) + + if os.path.isfile(archive_plot_filename + '.pdf'): + print('Plot {} already exists'.format(archive_plot_filename)) + return + + fig, ax = plt.subplots(1) + + + plt.title( + 'Kumulative Impfrate (Erst- und Zweitimpfung)\n' + 'Datenquelle: RKI, Stand: {}. Erstellung: {}, Ersteller: Benedikt Bastin, Lizenz: CC BY-SA 4.0\n'.format( + print_stand, print_today + ) + ) + + ax.grid() + + first_vaccinations_cumulative = data_first_vaccination['cumulative'] + second_vaccinations_cumulative = data_second_vaccination['cumulative'] + + ax.fill_between(dates, first_vaccinations_cumulative, label='Erstimpfungen', color='blue') + ax.fill_between(dates, second_vaccinations_cumulative, label='Zweitimpfungen', color='lightblue') + + ax.set_ylim([0, first_vaccinations_cumulative.iloc[-1]]) + + ax.legend(loc='upper left') + ax.xaxis_date() + ax.get_yaxis().get_major_formatter().set_scientific(False) + + ax.set_xlabel('Datum') + ax.set_ylabel('Tägliche Impfungen') + + + plt.savefig(archive_plot_filename + '.pdf') + plt.savefig(archive_plot_filename + '.png') + plt.savefig(latest_plot_filename + '.pdf') + plt.savefig(latest_plot_filename + '.png') + plt.close() + + print('Created plot {} as pdf and png'.format(archive_plot_filename)) + + +plot_cumulative_two_vaccinations() + def render_dashboard(): dashboard_filename = 'site/index.xhtml' dashboard_archive_filename = 'site/archive/{}/index.xhtml'.format(filename_stand)