From 204195ac066a11e9994a3ada4a5539b6dd99c755 Mon Sep 17 00:00:00 2001 From: Felix Blanke Date: Mon, 28 Aug 2023 12:12:42 +0200 Subject: [PATCH] Allow multiple target lines --- wsgi.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/wsgi.py b/wsgi.py index 157aa94..3ecbe13 100644 --- a/wsgi.py +++ b/wsgi.py @@ -82,7 +82,7 @@ def plot( current_df: pd.DataFrame | None = None, data_folder: str = "data", sheet_name: str = "digital", - total_target: int = 1500, + total_targets: tuple[int, ...] = (1500, ), alpha: float | None = None, ) -> str: curr_datetime = datetime.datetime.now() @@ -132,9 +132,7 @@ def plot( plt.title("Teilnahme an Digitaler Beschäftigtenbefragung") plt.ylabel("# Teilnahmen") - plt.ylim(0, total_target + 100) - - # plt.gcf().autofmt_xdate() + plt.ylim(0, total_targets[0] + 100) # use timezone offset to center tick labels plt.gca().xaxis.set_major_locator( @@ -149,16 +147,18 @@ def plot( plt.gca().tick_params("x", length=0, which="major") def val_to_perc(val): - return 100 * val / total_target + return 100 * val / total_targets[0] def perc_to_val(perc): - return perc * total_target / 100 + return perc * total_targets[0] / 100 sec_ax = plt.gca().secondary_yaxis("right", functions=(val_to_perc, perc_to_val)) sec_ax.set_ylabel("# Teilnahmen [% Erfolg]") sec_ax.yaxis.set_major_formatter(mtick.PercentFormatter()) - plt.axhline(y=total_target, color="#48a9be", linestyle="--") + for total_target in total_targets: + plt.axhline(y=total_target, color="#48a9be", linestyle="--") + plt.tight_layout() # Convert plot to SVG image