I want to create an animated, stacked bar chart.
There is a great tutorial, which shows how to animate line graphs.
However, for animating bar charts, the BarContainer object, does not have any attribute to 'set_data'. I am therefore forced to clear the figure axes each time, e.g. ,
fig=plt.figure()
def init():
plt.cla()
def animate(i):
p1 = plt.bar(x_points,y_heights,width,color='b')
return p1
anim = animation.FuncAnimation(fig,animate,init_func=init,frames=400,interval=10,blit=False)
Is there an alternative option, following the style of the link, such that I do not have to clear the axes each time? Thanks.