From a0daed66ad77afbf04b1545dc22a7a30f9629ff1 Mon Sep 17 00:00:00 2001 From: Felix Blanke Date: Fri, 1 Sep 2023 23:19:48 +0200 Subject: [PATCH] Fix shading --- wsgi.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/wsgi.py b/wsgi.py index b3eba1b..2e9834c 100644 --- a/wsgi.py +++ b/wsgi.py @@ -109,13 +109,6 @@ def plot( ) -> str: fig = plt.figure(dpi=300) - # fill weekends - max_date = curr_datetime + datetime.timedelta(days=1) - days = pd.date_range(start="2023-08-14", end=max_date) - for idx, day in enumerate(days[:-1]): - if day.weekday() >= 5: - plt.gca().axvspan(days[idx], days[idx + 1], alpha=0.2, color="gray") - for bez in landesbez_str: series = df.sum(axis=1) if bez is None else df[bez] plot_df = series.to_frame("Digitale Befragung").replace(0, np.nan) @@ -199,6 +192,18 @@ def plot( for total_target in total_targets: plt.axhline(y=total_target, color="#48a9be", linestyle="--") + xlim = plt.xlim() + + # fill weekends + max_date = curr_datetime + datetime.timedelta(days=3) + days = pd.date_range(start="2023-08-14", end=max_date) + for idx, day in enumerate(days[:-1]): + if day.weekday() >= 5: + plt.gca().axvspan(days[idx], days[idx + 1], alpha=0.2, color="gray") + + # reset xlim + plt.xlim(xlim) + plt.tight_layout() return fig