I have the following script using matplotlib.animations that returns animated yield curve plot over-time which work fine :
test = pd.read_csv("test.csv")
test = test.iloc[:, 1:]
test = test.to_numpy()
date = test.iloc[:, 0]
plots = []
fig, ax = plt.subplots()
for i in test:
plots.append(ax.plot(tenor, i, color="b"))
ani = animation.ArtistAnimation(fig, plots, interval=30, repeat_delay=1000)
plt.show()
But now I also want that the date-time of each curve to be also animated (like here : http://freerangestats.info/blog/2019/04/20/yield-curve), so i tried this but I got the following error message : 'list' object has no attribute 'set_visible'
plots = []
fig, ax = plt.subplots()
for i, d in zip(test, date):
text = ax.text(-5, 60, f"{d}")
plots.append([ax.plot(tenor, i, color="b"), text])
ani = animation.ArtistAnimation(fig, plots, interval=30, repeat_delay=1000)
plt.show()
Thank ! :)