Add option to not fix lims in plot
This commit is contained in:
parent
dbf477ed17
commit
ef8cab6330
5
wsgi.py
5
wsgi.py
@ -96,6 +96,7 @@ def plot(
|
|||||||
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,
|
||||||
) -> str:
|
) -> str:
|
||||||
fig = plt.figure(dpi=300)
|
fig = plt.figure(dpi=300)
|
||||||
|
|
||||||
@ -125,7 +126,7 @@ def plot(
|
|||||||
ls="--",
|
ls="--",
|
||||||
marker="o",
|
marker="o",
|
||||||
lw=1,
|
lw=1,
|
||||||
color="#e4004e" if bez is None else None,
|
color="#e4004e" if bez is None or not fix_lims else None,
|
||||||
markersize=4,
|
markersize=4,
|
||||||
label=bez if bez is not None else "Bundesweit",
|
label=bez if bez is not None else "Bundesweit",
|
||||||
)
|
)
|
||||||
@ -152,6 +153,7 @@ def plot(
|
|||||||
plt.title("Teilnahme an Digitaler Beschäftigtenbefragung")
|
plt.title("Teilnahme an Digitaler Beschäftigtenbefragung")
|
||||||
plt.ylabel("# Teilnahmen")
|
plt.ylabel("# Teilnahmen")
|
||||||
|
|
||||||
|
if fix_lims:
|
||||||
max_val = df.sum(axis=1).max().item()
|
max_val = df.sum(axis=1).max().item()
|
||||||
|
|
||||||
nearest_target = np.array(total_targets, dtype=np.float32) - max_val
|
nearest_target = np.array(total_targets, dtype=np.float32) - max_val
|
||||||
@ -184,6 +186,7 @@ def plot(
|
|||||||
sec_ax.set_ylabel("# Teilnahmen [% Erfolg]")
|
sec_ax.set_ylabel("# Teilnahmen [% Erfolg]")
|
||||||
sec_ax.yaxis.set_major_formatter(mtick.PercentFormatter())
|
sec_ax.yaxis.set_major_formatter(mtick.PercentFormatter())
|
||||||
|
|
||||||
|
if fix_lims:
|
||||||
for total_target in total_targets:
|
for total_target in total_targets:
|
||||||
plt.axhline(y=total_target, color="#48a9be", linestyle="--")
|
plt.axhline(y=total_target, color="#48a9be", linestyle="--")
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user