Simplify plot

This commit is contained in:
Felix Blanke 2023-09-07 12:37:02 +02:00
parent 40c30fdde8
commit d2d157c479

View File

@ -104,13 +104,13 @@ def create_plot_df(
def plot( def plot(
curr_datetime,
df: pd.DataFrame, df: pd.DataFrame,
annotate_current: bool = False, annotate_current: bool = False,
total_targets: tuple[int, ...] = (1500, 2500, 3500), total_targets: tuple[int, ...] = (1500, 2500, 3500),
alpha: float | None = None, alpha: float | None = None,
landesbez_str: str | None = None, landesbez_str: str | None = None,
fix_lims: bool = True, fix_lims: bool = True,
max_shading_date = None,
) -> str: ) -> str:
fig = plt.figure(dpi=300) fig = plt.figure(dpi=300)
@ -200,8 +200,9 @@ def plot(
xlim = plt.xlim() xlim = plt.xlim()
# fill weekends # fill weekends
max_date = curr_datetime + datetime.timedelta(days=3) if max_shading_date is None:
days = pd.date_range(start="2023-08-14", end=max_date) max_shading_date = df.index.max() + datetime.timedelta(days=3)
days = pd.date_range(start="2023-08-14", end=max_shading_date)
for idx, day in enumerate(days[:-1]): for idx, day in enumerate(days[:-1]):
if day.weekday() >= 5: if day.weekday() >= 5:
plt.gca().axvspan(days[idx], days[idx + 1], alpha=0.2, color="gray") plt.gca().axvspan(days[idx], days[idx + 1], alpha=0.2, color="gray")
@ -262,7 +263,6 @@ def create_fig(
] ]
return ( return (
plot( plot(
curr_datetime,
plot_df, plot_df,
annotate_current=annotate_current, annotate_current=annotate_current,
landesbez_str=landesbez_strs, landesbez_str=landesbez_strs,