Make ylim rendering dynamic

This commit is contained in:
Felix Blanke 2023-08-31 11:30:48 +02:00
parent 87f54c6fef
commit bd804f1464

10
wsgi.py
View File

@ -151,7 +151,15 @@ def plot(
plt.title("Teilnahme an Digitaler Beschäftigtenbefragung")
plt.ylabel("# Teilnahmen")
plt.ylim(0, total_targets[0] + 100)
max_val = df.sum(axis=1).max().item()
nearest_target = np.array(total_targets, dtype=np.float32) - max_val
nearest_target[nearest_target <= 0] = np.inf
idx = np.argmin(nearest_target)
ceil_val = max(max_val, total_targets[idx])
plt.ylim(0, ceil_val * 1.025)
plt.legend()
# use timezone offset to center tick labels