On 10/13/2013 7:49 PM, Aiyong WANG wrote: > Today I setuped a ubuntu virtual machine, installed matplotlib 1.3.1 > (builded and installed from source), installed ImageMagick via > 'apt-get', and tried again that sample. > It worked. > > So Does the imagemagick writer not work on Windows, or am I missing > something in my Win7 ? > > Can anybody help ? > Thank you. > > > 2013/10/13 Aiyong WANG <gepcel...@gmail.com <mailto:gepcel...@gmail.com>> > > Hi. > I'm using windows 7, with python(x,y) 2.7.5.0 installed. I then > installed matplotlib 1.3.1 and imagemagick. > Something goes wrong when try to save animation as a gif file. > I used a base_animation.py within ipython notebook as followed: > > code: > > ------------------------------------------------------------------------------------- > import numpy as np > from matplotlib import pyplot as plt > from matplotlib import animation > # First set up the figure, the axis, and the plot element we want to > animate > fig = plt.figure() > ax = fig.add_subplot(111, xlim=(0, 2), ylim=(-2, 2)) > line, = ax.plot([], [], lw=2) > # initialization function: plot the background of each frame > def init(): > line.set_data([], []) > return line, > # animation function. This is called sequentially > def animate(i): > x = np.linspace(0, 2, 1000) > y = np.sin(2 * np.pi * (x - 0.01 * i)) > line.set_data(x, y) > return line, > # call the animator. blit=True means only re-draw the parts that > have changed. > anim = animation.FuncAnimation(fig, animate, init_func=init, > frames=100, interval=20, blit=True) > # this is how you save your animation to file: > #anim.save('animation.gif', writer='imagemagick_file', fps=30) > anim.save('animation.gif', writer='imagemagick', fps=30) > plt.show() > > ---------------------------------------------------------------------------------- > > > > And I got an error message like this: > > > --------------------------------------------------------------------------- > RuntimeError Traceback (most recent call > last) > <ipython-input-2-7b2f7b9edcb4> in<module>() > 26 # this is how you save your animation to file: > 27 #anim.save('animation.gif', writer='imagemagick_file', fps=30) > ---> 28 anim.save('animation.gif', writer='imagemagick', fps=30) > 29 > 30 plt.show() > > D:\Python27\lib\site-packages\matplotlib\animation.pyc insave(self, > filename, writer, fps, dpi, codec, bitrate, extra_args, metadata, extra_anim, > savefig_kwargs) > 716 #TODO: Need to see if turning off blit is > really necessary > 717 anim._draw_next_frame(d, blit=False) > --> 718 writer.grab_frame(**savefig_kwargs) > 719 > 720 # Reconnect signal for first draw if necessary > > D:\Python27\lib\site-packages\matplotlib\animation.pyc > ingrab_frame(self, **savefig_kwargs) > 202 # frame format and dpi. > 203 self.fig.savefig(self._frame_sink(), > format=self.frame_format, > --> 204 dpi=self.dpi, **savefig_kwargs) > 205 except RuntimeError: > 206 out, err= self._proc.communicate() > > D:\Python27\lib\site-packages\matplotlib\figure.pyc insavefig(self, > *args, **kwargs) > 1419 self.set_frameon(frameon) > 1420 > -> 1421 self.canvas.print_figure(*args, **kwargs) > 1422 > 1423 if frameon: > > D:\Python27\lib\site-packages\matplotlib\backend_bases.pyc > inprint_figure(self, filename, dpi, facecolor, edgecolor, orientation, > format, **kwargs) > 2218 orientation=orientation, > 2219 bbox_inches_restore=_bbox_inches_restore, > -> 2220 **kwargs) > 2221 finally: > 2222 if bbox_inchesand restore_bbox: > > D:\Python27\lib\site-packages\matplotlib\backends\backend_agg.pyc > inprint_raw(self, filename_or_obj, *args, **kwargs) > 495 close= False > 496 try: > --> 497 renderer._renderer.write_rgba(filename_or_obj) > 498 finally: > 499 if close: > > RuntimeError: Error writing to file > > -- > > Can anybody help? > ------------------------------------------------------------------ > WANG Aiyong > > > > > -- > ------------------------------------------------------------------ > WANG Aiyong
`convert.exe` is a Windows system file. Set `animation.convert_path` in `matplotlib.rc` to the full path to ImageMagick's `convert.exe`. Works for me. Christoph ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users