如何平滑地绘制移动点

How to smoothly plot the moving dot

我想绘制一个从左到右移动的点。这是我的代码:

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.animation import FuncAnimation

Acc_11 = [0,1,2,3,4,5,6,7,8]
Acc_12 = [4,4,4,4,4,4,4,4,4]
fig = plt.figure()
axes = fig.add_subplot(111, autoscale_on=False)
axes.set_xlim(min(Acc_11), max(Acc_11))

axes.set_ylim(0, 8)


point, = axes.plot([Acc_11[0]],[Acc_12[0]], 'go')

def ani(coords):
   point.set_data([coords[0]],[coords[1]])
   return point,

def frames():
   for acc_11_pos, acc_12_pos in zip(Acc_11, Acc_12):
       yield acc_11_pos, acc_12_pos

ani = FuncAnimation(fig, ani, frames=frames, interval=300)

plt.show()

然而,点在每个点停止然后继续,但我希望点以这种速度平稳移动而不改变interval。有人可以帮忙吗?

在我看来,“流畅”总是需要“更多帧”。所以我没有看到一种方法可以使运动更平滑,即增加帧数,而不增加每秒帧数,即改变间隔。

这里是帧数增加十倍,间隔减少十倍的版本:

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.animation import FuncAnimation

Acc_11 = np.linspace(0,8,90)  # increased frames
Acc_12 = np.ones(len(Acc_11))*4
fig = plt.figure()
axes = fig.add_subplot(111, autoscale_on=False)
axes.set_xlim(min(Acc_11), max(Acc_11))

axes.set_ylim(0, 8)


point, = axes.plot([Acc_11[0]],[Acc_12[0]], 'go')

def ani(coords):
   point.set_data([coords[0]],[coords[1]])
   return point,

def frames():
   for acc_11_pos, acc_12_pos in zip(Acc_11, Acc_12):
       yield acc_11_pos, acc_12_pos

ani = FuncAnimation(fig, ani, frames=frames, interval=30)  # decreased interval

plt.show()