I want to create live plots of my results and found this SO question which did most of the job: Matplotlib animation update title using ArtistAnimation
BUT, when I start the script, the first figure shown is every figure at the same time (see screenshot below) What am I doing wrong? Also the axis is plotted twice but shifte (like in the initial figure) for each animation step. I would like to have the first plotted figure as the starting figure and then go to the next one after interval=1000
miliseconds.
I used the code from the other questions without any additions:
import matplotlib.pyplot as plt
from matplotlib import animation
import numpy as np
a = np.random.rand(10,10)
fig, ax=plt.subplots()
container = []
for i in range(a.shape[1]):
line, = ax.plot(a[:,i])
title = ax.text(0.5,1.05,"Title {}".format(i),
size=plt.rcParams["axes.titlesize"],
ha="center", transform=ax.transAxes, )
container.append([line, title])
ani = animation.ArtistAnimation(fig, container, interval=200, blit=False)
plt.show()
Using
Python=3.7.16
matplotlib==3.5.3