UNI_Python/_crashkurs/eval.py
2024-02-29 22:31:32 +01:00

39 lines
789 B
Python

import matplotlib.pyplot as plt
import matplotlib.animation as ani
import random as rnd
def update(frame):
participants = rnd.randint(1, 50)
answers = ["good", "good", "good", "okay", "okay", "bad"]
for participant in range(participants):
answer = rnd.choice(answers)
evals[answer] += 1
print(evals)
ax_evals.clear()
pie_update = ax_evals.pie(
evals.values(),
labels=evals.keys()
)
return (pie_update,)
evals = {
"good": 1,
"okay": 1,
"bad": 1
}
fig_evals, ax_evals = plt.subplots()
ax_evals.pie(
evals.values(),
labels=evals.keys()
)
ax_evals.set(title="Evaluations")
animate = ani.FuncAnimation(fig_evals, update, frames=200, interval=20)
animate.save('animate.gif', writer='pillow')
plt.show()