I've successfully animated a single bar chart using FuncAnimation, but I would now like to have 3 bar charts concurrently in subplots. I can't work out what my animation function should return. I tried to adapt my code for one bar chart to make it work for 3. This was my attempt but I get an error saying "AttributeError: 'BarContainer' object has no attribute 'get_zorder'". My data 'soln' is a 3x1000x10 list. The 3 is for each subplot, and the 10 is for each bar.
I believe this is a minimum example.
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import animation
soln = np.array([[[1, 0, 0],[1,1,0],[1, 2, 3]],[[1, 0, 0],[1,1,0],[1, 2, 3]],[[1, 0, 0],[1,1,0],[1, 2, 3]]])
print(soln.shape)
def animate(frame):
for i, list in enumerate(rects):
for j, rect in enumerate(list):
rect.set_height(soln[i, frame, j])
return rects
fig, axs = plt.subplots(1, 3)
xs = range(0, 3)
rects = []
for i in range(soln.shape[0]):
rects.append(axs[i].bar(xs, soln[i, 0, :]))
ani = animation.FuncAnimation(fig, animate, blit=True, repeat=False)