Как сделать так, чтобы график обновлялся каждый раз, после внесения новых данных?

Нужно, чтобы после внесения новых чисел в column_1, column_2 и column_3, происходило обновление графика.

Вот мой код:

import numpy as np 
import matplotlib.pyplot as plt 

X = ['Group A','Group B','Group C','Group D']
column_1 = [20,20,20,40]
column_2 = [20,30,25,30]
column_3 = [20,30,25,30]

X_axis = np.arange(len(X)) 

p = plt.bar(X_axis - 0.1, column_1, 0.2, label = 'p1')
p1 = plt.bar(X_axis + 0.1, column_2, 0.2, label = 'p2')
p3 = plt.bar(X_axis + 0.3, column_3, 0.2, label = 'p3')

plt.bar_label(p,  label_type='center', rotation=90, color='white') 
plt.bar_label(p1,  label_type='center', rotation=90, color='white') 
plt.bar_label(p3,  label_type='center', rotation=90, color='white') 

plt.xticks(X_axis, X)
plt.xlabel("Groups")
plt.ylabel("Number of Students")
plt.title("Number of Students in each group")
plt.legend()
plt.show()

Ответы (0 шт):