<div dir="ltr">I am having a problem animating a histogram and movie at the same time using matplotlib.animation.ArtistAnimation.<div><br></div><div>The first program below, which makes an animated histogram using the "bar" routine works fine.  If I substitute the two lines commented out for the two lines preceding those lines, it still works fine (using "plot" instead of 'bar").  For reasons that are not clear to me, I need make a list (ims) for animation for the histogram using the "bar" routine, and a list of lists for animation of the simple "plot" routine.<div><br></div><div>There is a more serious problem with the second routine where I simultaneously animate a sequence of images using imshow and also try to make an animated histogram.  It works fine if I plot the "histogram" using the "plot" routine but does not work if I use the "bar" routine.  Can someone offer some help?</div><div><br></div><div>I am running these on OSX 10.12.5, Python 3.5.2 or Python 3.6.1, and matplotlib 2.0.0 or 2.0.2<br><div><br></div><div><div>----------------------------</div></div><div><br></div><div><div>import numpy as np</div><div>import matplotlib.pyplot as plt</div><div>import matplotlib.animation as animation</div><div><br></div><div>fig, ax = plt.subplots()</div><div><br></div><div>ims = []</div><div>xh = np.random.randn(10)</div><div>for i in range(100):</div><div>    xh = np.append(xh, np.random.randn(10))</div><div>    a, b = np.histogram(xh, bins=24, normed=True)</div><div>    xx = 0.5*(b[:-1]+b[1:])</div><div>    ax.set_xlim(-3, 3)</div><div>    ax.set_ylim(0, 0.5)</div><div>    im = ax.bar(xx, a, width=0.9*(b[1]-b[0]), color='C1')</div><div>    ims.append(im)</div><div>    # im, = ax.plot(xx, a, '-oC0')</div><div>    # ims.append([im])</div><div><br></div><div>ani = animation.ArtistAnimation(fig, artists=ims, interval=50,</div><div>                                repeat=False)</div><div>plt.show()</div></div><div><br></div><div>----------------------------</div><div><br></div><div><div>import numpy as np</div><div>import matplotlib.pyplot as plt</div><div>import matplotlib.animation as animation</div><div><br></div><div><br></div><div>def f(x, y):</div><div>    return np.sin(x) + np.cos(y)</div><div><br></div><div>xm = np.linspace(0, 2 * np.pi, 120)</div><div>ym = np.linspace(0, 2 * np.pi, 120).reshape(-1, 1)</div><div><br></div><div>fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 3.5))</div><div>ax1.axis('off')</div><div><br></div><div>ims = []</div><div>xh = np.random.randn(10)</div><div>for i in range(100):</div><div>    xm += np.pi / 20.</div><div>    ym += np.pi / 20.</div><div>    im1 = ax1.imshow(f(xm, ym), cmap=plt.get_cmap('plasma'),</div><div>                     aspect='equal', animated=True)</div><div><br></div><div>    xh = np.append(xh, np.random.randn(10))</div><div>    a, b = np.histogram(xh, bins=24, normed=True)</div><div>    xx = 0.5*(b[:-1]+b[1:])</div><div>    ax2.set_xlim(-3, 3)</div><div>    ax2.set_ylim(0, 0.5)</div><div>    # im2 = ax2.bar(xx, a, width=0.9*(b[1]-b[0]), color='C1')</div><div>    im2, = ax2.plot(xx, a, '-oC0')</div><div>    ims.append([im1, im2])</div><div><br></div><div>ani = animation.ArtistAnimation(fig, artists=ims, interval=50,</div><div>                                repeat=False)</div><div># ani.save('junk.mp4')</div><div>plt.show()</div></div><div><br></div><div><div>----------------------------</div></div><div><br></div></div></div></div>