feat: Added new bar plot with two bars instead of stacked bars
This commit is contained in:
parent
372d02d122
commit
7880d13202
2 changed files with 63 additions and 2 deletions
|
@ -191,11 +191,24 @@
|
||||||
</a>
|
</a>
|
||||||
<figcaption>
|
<figcaption>
|
||||||
<a name="figure-004"><span class="ref">Abbildung 4:</span></a>
|
<a name="figure-004"><span class="ref">Abbildung 4:</span></a>
|
||||||
Tägliche Impfrate (Erst- und Zweitimpfung)<br />
|
Tägliche Impfrate (Erst- und Zweitimpfung übereinander)<br />
|
||||||
<a href="vaccination_bar_graph_total_time.png" download="vaccination_bar_graph_total_time.png">Download als PNG</a>
|
<a href="vaccination_bar_graph_total_time.png" download="vaccination_bar_graph_total_time.png">Download als PNG</a>
|
||||||
<a href="vaccination_bar_graph_total_time.pdf" download="vaccination_bar_graph_total_time.pdf">Download als PDF</a>
|
<a href="vaccination_bar_graph_total_time.pdf" download="vaccination_bar_graph_total_time.pdf">Download als PDF</a>
|
||||||
</figcaption>
|
</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
|
<figure>
|
||||||
|
<a href="vaccination_bar_graph_total_time_two_bars.png">
|
||||||
|
<img
|
||||||
|
src="vaccination_bar_graph_total_time_two_bars.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_total_time_two_bars.png" download="vaccination_bar_graph_total_time_two_bars.png">Download als PNG</a>
|
||||||
|
<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>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
|
50
plot.py
50
plot.py
|
@ -12,6 +12,8 @@ import locale
|
||||||
import os.path
|
import os.path
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
|
from matplotlib.dates import date2num
|
||||||
|
|
||||||
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
|
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
|
||||||
|
|
||||||
site_folder = 'site/'
|
site_folder = 'site/'
|
||||||
|
@ -332,7 +334,7 @@ def plot_vaccination_bar_graph_total_time():
|
||||||
|
|
||||||
|
|
||||||
plt.title(
|
plt.title(
|
||||||
'Tägliche Impfrate (Erst- und Zweitimpfung)\n'
|
'Tägliche Impfrate (Erst- und Zweitimpfung übereinander)\n'
|
||||||
'Datenquelle: RKI, Stand: {}. Erstellung: {}, Ersteller: Benedikt Bastin, Lizenz: CC BY-SA 4.0\n'.format(
|
'Datenquelle: RKI, Stand: {}. Erstellung: {}, Ersteller: Benedikt Bastin, Lizenz: CC BY-SA 4.0\n'.format(
|
||||||
print_stand, print_today
|
print_stand, print_today
|
||||||
)
|
)
|
||||||
|
@ -362,6 +364,52 @@ def plot_vaccination_bar_graph_total_time():
|
||||||
|
|
||||||
plot_vaccination_bar_graph_total_time()
|
plot_vaccination_bar_graph_total_time()
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
fig, ax = plt.subplots(1)
|
||||||
|
|
||||||
|
|
||||||
|
plt.title(
|
||||||
|
'Tägliche Impfrate (Erst- und Zweitimpfung nebeneinander)\n'
|
||||||
|
'Datenquelle: RKI, Stand: {}. Erstellung: {}, Ersteller: Benedikt Bastin, Lizenz: CC BY-SA 4.0\n'.format(
|
||||||
|
print_stand, print_today
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
ax.grid()
|
||||||
|
|
||||||
|
date_numbers = date2num(dates)
|
||||||
|
|
||||||
|
ax.bar(date_numbers - 0.2, data_first_vaccination['daily'], width=0.4, label='Tägliche Erstimpfungen', color='blue')
|
||||||
|
ax.bar(date_numbers + 0.2, data_second_vaccination['daily'], width=0.4, label='Tägliche Zweitimpfungen', color='lightblue')
|
||||||
|
|
||||||
|
ax.set_ylim([0, 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_total_time_two_bars()
|
||||||
|
|
||||||
def render_dashboard():
|
def render_dashboard():
|
||||||
dashboard_filename = 'site/index.xhtml'
|
dashboard_filename = 'site/index.xhtml'
|
||||||
dashboard_archive_filename = 'site/archive/{}/index.xhtml'.format(filename_stand)
|
dashboard_archive_filename = 'site/archive/{}/index.xhtml'.format(filename_stand)
|
||||||
|
|
Loading…
Reference in a new issue