diff --git a/plot.py b/plot.py index b9fbef9..c3604cd 100644 --- a/plot.py +++ b/plot.py @@ -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)