Я пытаюсь сгенерировать GIF для изображения, которое я создал. Тем не менее, я сталкиваюсь с этим сообщением об ошибке
MovieWriter imagemagick unavailable; trying to use <class 'matplotlib.animation.PillowWriter'> instead.
~\Anaconda3\lib\site-packages\matplotlib\animation.py in finish(self)
573
574 def finish(self):
--> 575 self._frames[0].save(
576 self._outfile, save_all=True, append_images=self._frames[1:],
577 duration=int(1000 / self.fps), loop=0)
IndexError: list index out of range
Вот мой код
from matplotlib import animation, rc
#Set the plot up,
fig = plt.figure()
ax = plt.axes()
plt.title('Sale Price vs Living Area')
plt.xlabel('Living Area in square feet (normalised)')
plt.ylabel('Sale Price ($)')
plt.scatter(x[:,1], y, color='red')
line, = ax.plot([], [], lw=2)
annotation = ax.text(-1, 700000, '')
annotation.set_animated(True)
plt.close()
#Generate the animation data,
def init():
line.set_data([], [])
annotation.set_text('')
return line, annotation
def animate(i):
x = np.linspace(-5, 20, 1000)
y = past_thetas[i][1]*x + past_thetas[i][0]
line.set_data(x, y)
annotation.set_text('Cost = %.2f e10' % (past_costs[i]/10000000000))
return line, annotation
anim = animation.FuncAnimation(fig, animate, init_func=init,
frames=300, interval=0, blit=True)
anim.save('animation.gif', writer='imagemagick', fps = 30)
Это пример того, что у меня есть в past_thetas
[array([0.61279458, 0.07571964]),
array([5402.42825457, 2578.99911609]),
array([10750.22555995, 5132.1344718 ]),
array([16044.54489229, 7659.73965526]),
array([21285.9210313 , 10162.06995636]),
array([26474.88340892, 12639.37811224]),
array([31611.95616276, 15091.91433277]),
array([36697.65818907, 17519.92632585]),
array([41732.50319511, 19923.65932241]),
array([46716.99975109, 22303.35610116]),
array([51651.65134151, 24659.25701318]),
array([56536.95641603, 26991.60000612]),
array([61373.4084398 , 29300.62064827]),
array([66161.49594334, 31586.55215234]),
array([70901.70257184, 33849.62539904]),
array([75594.50713405, 36090.06896035]),
array([80240.38365065, 38308.10912268]),
array([84839.80140207, 40503.96990963]),
array([89393.22497599, 42677.87310471]),
array([93901.11431416, 44830.03827366]),
array([98363.92475895, 46960.6827867 ]),
array([102782.10709929, 49070.02184043]),
array([107156.10761624, 51158.26847958]),
array([111486.36812801, 53225.63361853]),
array([115773.32603466, 55272.32606263]),
array([120017.41436225, 57298.55252927]),
array([124219.06180656, 59304.51766874]),
array([128378.69277642, 61290.42408495]),
array([132496.72743659, 63256.47235584]),
array([136573.58175016, 65202.86105368]),
array([140609.66752059, 67129.78676511]),
array([144605.39243332, 69037.44411098]),
array([148561.16009692, 70926.02576604]),
array([152477.37008388, 72795.72247837]),
array([156354.41797098, 74646.72308865]),
array([160192.6953792 , 76479.21454926]),
array([163992.59001334, 78293.38194312]),
array([167754.48570114, 80089.40850244]),
array([171478.76243206, 81867.47562715]),
array([175165.79639568, 83627.76290331]),
array([178815.96001965, 85370.44812116]),
array([182429.62200739, 87095.70729314])]