Skip to content

Unable to save animation #16713

@khoo0157

Description

@khoo0157

Bug report

Bug summary

I am unable to save an animation using ffmpeg.

Code for reproduction

import matplotlib
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
    
x = []
y = []

Writer = matplotlib.animation.writers['ffmpeg']
writer = Writer(fps=15, metadata=dict(artist='Me'), bitrate=1800)

fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_xlim(0,500)
ax.set_ylim(0,1000)
line, = ax.plot(0,0,'r')


def AnimationFrame(i):
    x.append(i)
    y.append(i ** 1.5) 
    line.set_xdata(x)
    line.set_ydata(y)
    return line,
animation = FuncAnimation(fig, func=AnimationFrame, frames=range(0,200), interval = 100)

plt.show()
animation.save('im.mp4', writer=writer)

Actual outcome

Traceback (most recent call last):
  File "pypy.py", line 27, in <module>
    animation.save('im.mp4', writer=writer)
  File "C:\Users\yongj\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\matplotlib\animation.py", line 1156, in save
    writer.grab_frame(**savefig_kwargs)
  File "C:\Users\yongj\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\matplotlib\animation.py", line 380, in grab_frame
    self.fig.set_size_inches(self._w, self._h)
  File "C:\Users\yongj\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\matplotlib\figure.py", line 912, in set_size_inches
    manager.resize(int(canvasw), int(canvash))
  File "C:\Users\yongj\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\matplotlib\backends\_backend_tk.py", line 532, in resize
    self.canvas._tkcanvas.master.geometry("%dx%d" % (width, height))
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.752.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 2035, in wm_geometry
    return self.tk.call('wm', 'geometry', self._w, newGeometry)
_tkinter.TclError: can't invoke "wm" command: application has been destroyed

installed matplotlib using pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy