Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Unable to save animation #16713

Copy link
Copy link
Closed
Closed
Copy link
@khoo0157

Description

@khoo0157
Issue body actions

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.