1
0
Fork 0

feat: Create plot only if it does not already exists

This commit is contained in:
Benedikt Bastin 2021-01-16 14:26:46 +01:00
parent 8c6eba2c4d
commit a75745c9af
1 changed files with 11 additions and 3 deletions

14
plot.py
View File

@ -9,7 +9,7 @@ import datetime
import re
import requests as req
import locale
import os.path
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
@ -82,9 +82,15 @@ filename_stand = stand_date.strftime("%Y%m%d%H%M%S")
def plot_extrapolation_portion(percentage):
print_percentage = int(percentage * 100)
plot_filename = '{}/{}_extrapolated_to_{}_percent.pdf'.format(plots_folder, filename_stand, print_percentage)
if os.path.isfile(plot_filename):
print('Plot {} already exists'.format(plot_filename))
return
fig, ax = plt.subplots(1)
print_percentage = int(percentage * 100)
plt.title(
'Tägliche Impfquote, kumulierte Impfungen und lineare Extrapolation bis {:n} % der Bevölkerung Deutschlands\n'
@ -121,9 +127,11 @@ def plot_extrapolation_portion(percentage):
ax2.set_ylabel('Kumulierte Impfungen')
plt.savefig('{}/{}_extrapolated_to_{}_percent.pdf'.format(plots_folder, filename_stand, print_percentage))
plt.savefig(plot_filename)
plt.close()
print('Created plot {}'.format(plot_filename))
plot_extrapolation_portion(0.1)
plot_extrapolation_portion(1.0)