python-3.x - matplotlib.animation - 在曲线上移动点
问题描述
我正在尝试做一个简单的动画:在曲线上移动一个点,但我不太明白我的错误。
有人可以骂我吗?谢谢
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig, ax = plt.subplots()
# ax.set_facecolor('black')
x = np.arange(0.0, 10, 0.5)
y = np.arange(10, 20, 0.5)
line =plt.plot(x,y)
dot, =plt.plot([0],[y[0]],'ro', markersize=5)
def init():
dot.set_data([],[])
return(dot, )
def animate(i):
dot.set_data(i, y[i])
return(dot, )
a = animation.FuncAnimation(fig, animate, init_func=init, frames=np.arange(0.0, 10), interval=50, blit=True)
plt.show()
解决方案
推荐阅读
- c - 使用 fork() 生成进程树
- python - 如何验证 tkinter 条目
- javascript - 将电子邮件传输到 API
- python - 是否可以使用 pyperclip 复制保存在数据库中的详细信息?
- c# - 根据数据库组织你的课程
- android - What is the benefit of using RxJava, RxKotlin, or Even Kotlin coroutines instead of Interfaces for On Click listener?
- android - 如何解决图像中的代码问题?
- http - Google Cloud Run 和 Dart vm 上的管道套接字异常 (errno=32)
- asynchronous - 有没有办法在锈异步中同时轮询几个期货
- google-apps-script - 将 Google Sheets 表格复制到 Google Document - 布尔单元格错误