pythonでアニメーションを保存しようとするとエラーがでます。
python
1import numpy as np 2import matplotlib.pyplot as plt 3import matplotlib.animation as animation 4 5fig = plt.figure() 6x = np.arange(0, 10, 0.1) 7 8ims = [] 9for a in range(50): 10 y = np.sin(x - a) 11 im = plt.plot(x, y, "r") 12 ims.append(im) 13 14ani = animation.ArtistAnimation(fig, ims) 15 16plt.show() 17ani.save("hoge.gif") 18
AttributeError Traceback (most recent call last)
/Users/~/demo.py in <module>()
15
16 plt.show()
---> 17 ani.save("hoge.mp4")
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/animation.pyc in save(self, filename, writer, fps, dpi, codec, bitrate, extra_args, metadata, extra_anim, savefig_kwargs)
724 # since GUI widgets are gone. Either need to remove extra code to
725 # allow for this non-existant use case or find a way to make it work.
--> 726 with writer.saving(self._fig, filename, dpi):
727 for data in itertools.izip(*[a.new_saved_frame_seq()
728 for a in all_anim]):
AttributeError: 'str' object has no attribute 'saving'
環境は
macos yosemite 10.10.5
python 2.7.10
matplotlib 10.10.5
です。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/10/23 16:24