使用 matplotlib.ArtistAnimation 的动画标题
我有以下使用 matplotlib.animations 的脚本,它随时间返回动画收益率曲线图,效果很好:
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()
但现在我还希望每条曲线的日期时间也进行动画处理(如下所示: http://freerangestats.info/blog/2019/04/20/yield-curve),所以我尝试了这个,但收到以下错误消息:“list”对象没有属性“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()
感谢 ! :)
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 ! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论