fix: Refactored saving plots into seperate function
This commit is contained in:
parent
5b8d0499c5
commit
bbea5ae532
1 changed files with 18 additions and 66 deletions
84
plot.py
84
plot.py
|
@ -286,6 +286,14 @@ else:
|
|||
os.mkdir(archive_folder)
|
||||
|
||||
|
||||
def save_plot(archive_plot_filename, latest_plot_filename):
|
||||
plt.savefig(archive_plot_filename + '.pdf')
|
||||
plt.savefig(archive_plot_filename + '.png')
|
||||
plt.savefig(latest_plot_filename + '.pdf')
|
||||
plt.savefig(latest_plot_filename + '.png')
|
||||
|
||||
print('Created plot {} as pdf and png'.format(archive_plot_filename))
|
||||
|
||||
|
||||
def plot_vaccination_bar_graph_total_time():
|
||||
|
||||
|
@ -319,14 +327,9 @@ def plot_vaccination_bar_graph_total_time():
|
|||
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')
|
||||
save_plot(archive_plot_filename, latest_plot_filename)
|
||||
plt.close()
|
||||
|
||||
print('Created plot {} as pdf and png'.format(archive_plot_filename))
|
||||
|
||||
plot_vaccination_bar_graph_total_time()
|
||||
|
||||
|
@ -401,15 +404,9 @@ def plot_vaccination_bar_graph_total_time_by_week():
|
|||
ax.set_xlabel('Datum')
|
||||
ax.set_ylabel('Wöchentliche 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')
|
||||
save_plot(archive_plot_filename, latest_plot_filename)
|
||||
plt.close()
|
||||
|
||||
print('Created plot {} as pdf and png'.format(archive_plot_filename))
|
||||
|
||||
plot_vaccination_bar_graph_total_time_by_week()
|
||||
|
||||
def plot_vaccination_bar_graph_total_time_two_bars():
|
||||
|
@ -447,15 +444,9 @@ def plot_vaccination_bar_graph_total_time_two_bars():
|
|||
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')
|
||||
save_plot(archive_plot_filename, latest_plot_filename)
|
||||
plt.close()
|
||||
|
||||
print('Created plot {} as pdf and png'.format(archive_plot_filename))
|
||||
|
||||
plot_vaccination_bar_graph_total_time_two_bars()
|
||||
|
||||
def plot_vaccination_bar_graph_compare_both_vaccinations():
|
||||
|
@ -494,15 +485,9 @@ def plot_vaccination_bar_graph_compare_both_vaccinations():
|
|||
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')
|
||||
save_plot(archive_plot_filename, latest_plot_filename)
|
||||
plt.close()
|
||||
|
||||
print('Created plot {} as pdf and png'.format(archive_plot_filename))
|
||||
|
||||
plot_vaccination_bar_graph_compare_both_vaccinations()
|
||||
|
||||
def plot_cumulative_two_vaccinations():
|
||||
|
@ -540,15 +525,9 @@ def plot_cumulative_two_vaccinations():
|
|||
ax.set_xlabel('Datum')
|
||||
ax.set_ylabel('Kumulative 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')
|
||||
save_plot(archive_plot_filename, latest_plot_filename)
|
||||
plt.close()
|
||||
|
||||
print('Created plot {} as pdf and png'.format(archive_plot_filename))
|
||||
|
||||
|
||||
plot_cumulative_two_vaccinations()
|
||||
|
||||
|
@ -588,15 +567,9 @@ def plot_cumulative_two_vaccinations_percentage():
|
|||
ax.set_xlabel('Datum')
|
||||
ax.set_ylabel('Kumulative 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')
|
||||
save_plot(archive_plot_filename, latest_plot_filename)
|
||||
plt.close()
|
||||
|
||||
print('Created plot {} as pdf and png'.format(archive_plot_filename))
|
||||
|
||||
|
||||
plot_cumulative_two_vaccinations_percentage()
|
||||
|
||||
|
@ -638,15 +611,9 @@ def plot_people_between_first_and_second():
|
|||
ax.set_xlabel('Datum')
|
||||
ax.set_ylabel('Personen zwischen Erst- und Zweitimpfung')
|
||||
|
||||
|
||||
plt.savefig(archive_plot_filename + '.pdf')
|
||||
plt.savefig(archive_plot_filename + '.png')
|
||||
plt.savefig(latest_plot_filename + '.pdf')
|
||||
plt.savefig(latest_plot_filename + '.png')
|
||||
save_plot(archive_plot_filename, latest_plot_filename)
|
||||
plt.close()
|
||||
|
||||
print('Created plot {} as pdf and png'.format(archive_plot_filename))
|
||||
|
||||
|
||||
plot_people_between_first_and_second()
|
||||
|
||||
|
@ -689,14 +656,9 @@ def plot_vaccination_rate():
|
|||
ax.set_xlabel('Datum')
|
||||
ax.set_ylabel('Impfrate [Impfungen/Tag]')
|
||||
|
||||
plt.savefig(archive_plot_filename + '.pdf')
|
||||
plt.savefig(archive_plot_filename + '.png')
|
||||
plt.savefig(latest_plot_filename + '.pdf')
|
||||
plt.savefig(latest_plot_filename + '.png')
|
||||
save_plot(archive_plot_filename, latest_plot_filename)
|
||||
plt.close()
|
||||
|
||||
print('Created plot {} as pdf and png'.format(archive_plot_filename))
|
||||
|
||||
plot_vaccination_rate()
|
||||
|
||||
def plot_vaccination_done_days():
|
||||
|
@ -736,14 +698,9 @@ def plot_vaccination_done_days():
|
|||
ax.set_xlabel('Datum')
|
||||
ax.set_ylabel('Tage, bis 70 % erreicht sind')
|
||||
|
||||
plt.savefig(archive_plot_filename + '.pdf')
|
||||
plt.savefig(archive_plot_filename + '.png')
|
||||
plt.savefig(latest_plot_filename + '.pdf')
|
||||
plt.savefig(latest_plot_filename + '.png')
|
||||
save_plot(archive_plot_filename, latest_plot_filename)
|
||||
plt.close()
|
||||
|
||||
print('Created plot {} as pdf and png'.format(archive_plot_filename))
|
||||
|
||||
plot_vaccination_done_days()
|
||||
|
||||
def plot_vaccination_done_dates():
|
||||
|
@ -793,14 +750,9 @@ def plot_vaccination_done_dates():
|
|||
ax.set_xlabel('Datum')
|
||||
ax.set_ylabel('Datum, an dem 70 % erreicht sind')
|
||||
|
||||
plt.savefig(archive_plot_filename + '.pdf')
|
||||
plt.savefig(archive_plot_filename + '.png')
|
||||
plt.savefig(latest_plot_filename + '.pdf')
|
||||
plt.savefig(latest_plot_filename + '.png')
|
||||
save_plot(archive_plot_filename, latest_plot_filename)
|
||||
plt.close()
|
||||
|
||||
print('Created plot {} as pdf and png'.format(archive_plot_filename))
|
||||
|
||||
plot_vaccination_done_dates()
|
||||
|
||||
def render_dashboard():
|
||||
|
|
Loading…
Reference in a new issue