import matplotlib.image as mpimgimport numpy as npimport matplotlib.pyplot as pltimport matplotlib.animation as animationfrom matplotlib.widgets import Buttonfrom matplotlib.widgets import Sliderfig = plt.figure()image_list = ['downloads/20120831_194836_aia.lev1_euv_12s_4k.jpg', 'downloads/20120831_194936_aia.lev1_euv_12s_4k.jpg', 'downloads/20120831_195036_aia.lev1_euv_12s_4k.jpg']list = []for raw_image in image_list: image1 = mpimg.imread(raw_image) real_image1 = plt.imshow(image1) list.append([real_image1])def update_plot(t): print(t) return list[t]anim = animation.FuncAnimation(fig, update_plot, repeat = True, interval=1, blit=False, repeat_delay=200)plt.show()我正在嘗試使用列表中的 3 個 jpg 圖像創(chuàng)建一個 func 動畫。程序運行 3 個圖像 1 次后,出現(xiàn)錯誤。當(dāng)我打印“打印”時,它永遠不會重置為 0。錯誤:Traceback (most recent call last): File "/Users/jamisenma/opt/anaconda3/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 1194, in _on_timer ret = func(*args, **kwargs) File "/Users/jamisenma/opt/anaconda3/lib/python3.7/site-packages/matplotlib/animation.py", line 1447, in _step still_going = Animation._step(self, *args) File "/Users/jamisenma/opt/anaconda3/lib/python3.7/site-packages/matplotlib/animation.py", line 1173, in _step self._draw_next_frame(framedata, self._blit) File "/Users/jamisenma/opt/anaconda3/lib/python3.7/site-packages/matplotlib/animation.py", line 1192, in _draw_next_frame self._draw_frame(framedata) File "/Users/jamisenma/opt/anaconda3/lib/python3.7/site-packages/matplotlib/animation.py", line 1755, in _draw_frame self._drawn_artists = self._func(framedata, *self._args) File "/Users/jamisenma/Library/Application Support/JetBrains/PyCharmCE2020.1/scratches/scratch_59.py", line 19, in update_plot return list[t]IndexError: list index out of range有誰知道問題是什么?
當(dāng)我將 repeat = True 作為參數(shù)時,為什么 FuncAnimation 不重復(fù)?
慕尼黑5688855
2023-03-16 17:41:04