1
0
Fork 0

feat: Added plot for cumulative vaccinations in relation to population percentage

This commit is contained in:
Benedikt Bastin 2021-01-31 23:44:50 +01:00
parent c80564c801
commit 65df13923f
2 changed files with 63 additions and 1 deletions

View File

@ -231,12 +231,25 @@
alt="" />
</a>
<figcaption>
<a name="figure-006"><span class="ref">Abbildung 6:</span></a>
<a name="figure-007"><span class="ref">Abbildung 7:</span></a>
Tägliche Impfrate (Erst- und Zweitimpfung um 21 Tage versetzt)<br />
<a href="cumulative_two_vaccinations.png" download="cumulative_two_vaccinations.png">Download als PNG</a>
<a href="cumulative_two_vaccinations.pdf" download="cumulative_two_vaccinations.pdf">Download als PDF</a>
</figcaption>
</figure>
<figure>
<a href="cumulative_two_vaccinations_percentage.png">
<img
src="cumulative_two_vaccinations_percentage.png"
alt="" />
</a>
<figcaption>
<a name="figure-008"><span class="ref">Abbildung 8:</span></a>
Tägliche Impfrate (Erst- und Zweitimpfung um 21 Tage versetzt)<br />
<a href="cumulative_two_vaccinations_percentage.png" download="cumulative_two_vaccinations_percentage.png">Download als PNG</a>
<a href="cumulative_two_vaccinations_percentage.pdf" download="cumulative_two_vaccinations_percentage.pdf">Download als PDF</a>
</figcaption>
</figure>
</section>
<section>

49
plot.py
View File

@ -13,6 +13,7 @@ import os.path
import shutil
from matplotlib.dates import date2num
import matplotlib.ticker as mtick
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
@ -505,6 +506,54 @@ def plot_cumulative_two_vaccinations():
plot_cumulative_two_vaccinations()
def plot_cumulative_two_vaccinations_percentage():
archive_plot_filename = '{}/cumulative_two_vaccinations_percentage'.format(archive_folder)
latest_plot_filename = '{}/cumulative_two_vaccinations_percentage'.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) in Prozent der Bevökerung Deutschlands ({} Einwohner)\n'
'Datenquelle: RKI, Stand: {}. Erstellung: {}, Ersteller: Benedikt Bastin, Lizenz: CC BY-SA 4.0\n'.format(
'{:n}'.format(einwohner_deutschland).replace('.', ''),
print_stand, print_today
)
)
ax.grid()
first_vaccinations_cumulative = data_first_vaccination['cumulative'] / einwohner_deutschland
second_vaccinations_cumulative = data_second_vaccination['cumulative'] / einwohner_deutschland
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, 1])
ax.legend(loc='upper left')
ax.xaxis_date()
ax.yaxis.set_major_formatter(mtick.PercentFormatter(1.0))
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_percentage()
def render_dashboard():
dashboard_filename = 'site/index.xhtml'
dashboard_archive_filename = 'site/archive/{}/index.xhtml'.format(filename_stand)