Compare commits
3 Commits
976ddc6c23
...
bd804f1464
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd804f1464 | ||
|
|
87f54c6fef | ||
|
|
cc7ba64dd3 |
5
plot.py
5
plot.py
@ -1,15 +1,18 @@
|
||||
import datetime
|
||||
from pathlib import Path
|
||||
|
||||
import fire
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from wsgi import create_fig
|
||||
from wsgi import create_fig, create_plot_df
|
||||
|
||||
|
||||
def main(folder: str = "plots"):
|
||||
fig, _df, _df_state, timestamp = create_fig()
|
||||
timestamp = timestamp.replace(" ", "_")
|
||||
timestamp = timestamp.replace(":", "-")
|
||||
plot_df = create_plot_df(datetime.datetime.now(), _df_state)
|
||||
print(plot_df.sum(1))
|
||||
fig.savefig(Path(folder) / f"digital_plot_{timestamp}.png", dpi=300)
|
||||
|
||||
|
||||
|
||||
12
wsgi.py
12
wsgi.py
@ -93,7 +93,7 @@ def plot(
|
||||
curr_datetime,
|
||||
df: pd.DataFrame,
|
||||
annotate_current: bool = False,
|
||||
total_targets: tuple[int, ...] = (1500,),
|
||||
total_targets: tuple[int, ...] = (1500, 2500, 3500),
|
||||
alpha: float | None = None,
|
||||
landesbez_str: str | None = None,
|
||||
) -> str:
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user