I want to create a dynamic barplot, i.e. I want to visualize the change of the y-values over time.
The x-values remain the same.
All I could do at the moment is creating one barplot after the other.
But I have to close each window, then the next one appears.
My wish is that after an amount of seconds, the plot refreshs itself.
Is that possible?
Here is what I have, written in Thonny IDE:
import matplotlib.pyplot as plt
import numpy as np
import random
x_val = [1,2,3,4]
y_val_array = [
[0.5, 0.3, 0.7, 0.8],
[0.6, 0.2, 0.7, 0.7],
[0.65, 0.1, 0.7, 0.6],
[0.66, 0.0, 0.7, 0.5],
[0.66, 0.0, 0.7, 0.4],
]
for i in range(0, 4):
y_val = y_val_array[i]
y_pos = np.arange(len(x_val))
plt.bar(y_pos, y_val, align='center')
plt.xticks(y_pos, x_val)
plt.show()
2