def line_many():
plt.ion()********
for i in range(100):
plt.clf()*********
name_list = ['0',"1","2","3","4","5","6"]
num_list = [round(random.random()*100,2),round(random.random()*100,2),round(random.random()*100,2),round(random.random()*100,2),round(random.random()*100,2),round(random.random()*100,2),round(random.random()*100,2)]
rects = plt.bar(range(len(num_list)), num_list, color='rgby')
# X軸標題
index = [0, 1, 2, 3,4,5,6]
index = [float(c) for c in index]
plt.ylim(ymax=110, ymin=0)
plt.xticks(index, name_list)
plt.ylabel("arrucay(%)") # X軸標籤
for rect in rects:
height = rect.get_height()
plt.text(rect.get_x() + rect.get_width() / 2, height, str(height) + '%', ha='center', va='bottom')
plt.pause(0.5) *******
plt.ioff()********
實現動態的關鍵就在********標記的四句