You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
789 B

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()