matplotlib.animation.AbstractMovieWriter#
- classmatplotlib.animation.AbstractMovieWriter(fps=5,metadata=None,codec=None,bitrate=None)[source]#
Abstract base class for writing movies, providing a way to grab frames bycalling
grab_frame.setupis called to start the process andfinishis called afterwards.savingis provided as a context manager to facilitate this process aswithmoviewriter.saving(fig,outfile='myfile.mp4',dpi=100):# Iterate over framesmoviewriter.grab_frame(**savefig_kwargs)
The use of the context manager ensures that
setupandfinishareperformed as necessary.An instance of a concrete subclass of this class can be given as the
writerargument ofAnimation.save().Methods
__init__([fps, metadata, codec, bitrate])finish()Finish any processing for writing the movie.
grab_frame(**savefig_kwargs)Grab the image information from the figure and save as a movie frame.
saving(fig, outfile, dpi, *args, **kwargs)Context manager to facilitate writing the movie file.
setup(fig, outfile[, dpi])Setup for writing the movie file.
Attributes
A tuple
(width,height)in pixels of a movie frame.- propertyframe_size#
A tuple
(width,height)in pixels of a movie frame.
- abstractmethodgrab_frame(**savefig_kwargs)[source]#
Grab the image information from the figure and save as a movie frame.
All keyword arguments insavefig_kwargs are passed on to the
savefigcall that saves the figure. However, severalkeyword arguments that are supported bysavefigmay not bepassed as they are controlled by the MovieWriter:- dpi,bbox_inches: These may not be passed because each frame of the
animation much be exactly the same size in pixels.
format: This is controlled by the MovieWriter.
- saving(fig,outfile,dpi,*args,**kwargs)[source]#
Context manager to facilitate writing the movie file.
*args,**kware any parameters that should be passed tosetup.
- abstractmethodsetup(fig,outfile,dpi=None)[source]#
Setup for writing the movie file.
- Parameters:
- fig
Figure The figure object that contains the information for frames.
- outfilestr
The filename of the resulting movie file.
- dpifloat, default:
fig.dpi The DPI (or resolution) for the file. This controls the sizein pixels of the resulting movie file.
- fig