【发布时间】:2020-05-22 04:15:19
【问题描述】:
我在这里尝试显示下颌线的动画。运行代码会在调用 OnClicked() 事件时出错。
def OnClicked(self, e):
print("ok")
self.ani = animation.FuncAnimation(self.figure_animation, self.animate , init_func=self.init, interval=0.1,
blit=True)
def init(self): # only required for blitting to give a clean slate.
x = self.mat_px[0]
y = self.mat_py[0]
self.jaw_outline.set_data(x, y)
return self.img, self.jaw_outline
def animate(self, i):
# update the data
x = self.mat_px[i]
y = self.mat_py[i]
self.jaw_outline.set_data(x, y)
poa = self.axes_animation.scatter(self.h2_POA_pos[i], self.K2_POA_pos[i], color='red', s=150)
jaw_area_fill = self.axes_animation.fill_between(x, y, 0, facecolor=[(254 / 255, 157 / 255, 111 / 255)])
return self.img, self.jaw_outline, jaw_area_fill, poa
考虑如果 self.mat_px 的长度为 80,那么我在 pycharm 控制台中不断收到“index 80 is out of bounds for axis 0 with size 80”错误。我收到类似下面的不间断错误。
- IndexError:索引 80 超出轴 0 的范围,大小为 75。
- IndexError:索引 81 超出轴 0 的范围,大小为 75。
- IndexError:索引 82 超出轴 0 的范围,大小为 75。
- 等等
如果我将 blit 设置为 False,那么我不会收到任何错误,但这样做不会给我正确的结果。 请帮我解决这个问题。
【问题讨论】: