feat: Create plot only if it does not already exists
This commit is contained in:
parent
8c6eba2c4d
commit
a75745c9af
1 changed files with 11 additions and 3 deletions
14
plot.py
14
plot.py
|
@ -9,7 +9,7 @@ import datetime
|
||||||
import re
|
import re
|
||||||
import requests as req
|
import requests as req
|
||||||
import locale
|
import locale
|
||||||
|
import os.path
|
||||||
|
|
||||||
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
|
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):
|
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)
|
fig, ax = plt.subplots(1)
|
||||||
|
|
||||||
print_percentage = int(percentage * 100)
|
|
||||||
|
|
||||||
plt.title(
|
plt.title(
|
||||||
'Tägliche Impfquote, kumulierte Impfungen und lineare Extrapolation bis {:n} % der Bevölkerung Deutschlands\n'
|
'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')
|
ax2.set_ylabel('Kumulierte Impfungen')
|
||||||
|
|
||||||
plt.savefig('{}/{}_extrapolated_to_{}_percent.pdf'.format(plots_folder, filename_stand, print_percentage))
|
plt.savefig(plot_filename)
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
|
print('Created plot {}'.format(plot_filename))
|
||||||
|
|
||||||
|
|
||||||
plot_extrapolation_portion(0.1)
|
plot_extrapolation_portion(0.1)
|
||||||
plot_extrapolation_portion(1.0)
|
plot_extrapolation_portion(1.0)
|
||||||
|
|
Loading…
Reference in a new issue