1
0
Fork 0

feat: Added new bar plot comparing both vaccination rates day aligned

This commit is contained in:
Benedikt Bastin 2021-01-31 21:56:34 +01:00
parent 7880d13202
commit d080790995
2 changed files with 63 additions and 3 deletions

View File

@ -209,6 +209,19 @@
<a href="vaccination_bar_graph_total_time_two_bars.pdf" download="vaccination_bar_graph_total_time_two_bars.pdf">Download als PDF</a>
</figcaption>
</figure>
<figure>
<a href="vaccination_bar_graph_compare_both_vaccinations.png">
<img
src="vaccination_bar_graph_compare_both_vaccinations.png"
alt="" />
</a>
<figcaption>
<a name="figure-004"><span class="ref">Abbildung 4:</span></a>
Tägliche Impfrate (Erst- und Zweitimpfung nebeneinander)<br />
<a href="vaccination_bar_graph_compare_both_vaccinations.png" download="vaccination_bar_graph_compare_both_vaccinations.png">Download als PNG</a>
<a href="vaccination_bar_graph_compare_both_vaccinations.pdf" download="vaccination_bar_graph_compare_both_vaccinations.pdf">Download als PDF</a>
</figcaption>
</figure>
</section>
<section>

53
plot.py
View File

@ -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)