Skip to content

directory-of-files MovieWriter subclass #7679

@tacaswell

Description

@tacaswell

Derived from https://stackoverflow.com/questions/41230286/matplotlib-animation-write-to-png-files-without-third-party-module

Some version of my answer http://stackoverflow.com/a/41273312/380231

import matplotlib.animation as ma


class BunchOFiles(ma.FileMovieWriter):
    def setup(self, fig, dpi, frame_prefix):
        super().setup(fig, dpi, frame_prefix, clear_temp=False)

    def _run(self):
        # Uses subprocess to call the program for assembling frames into a
        # movie file.  *args* returns the sequence of command line arguments
        # from a few configuration options.
        pass

    def grab_frame(self, **savefig_kwargs):
        '''
        Grab the image information from the figure and save as a movie frame.
        All keyword arguments in savefig_kwargs are passed on to the 'savefig'
        command that saves the figure.
        '''

        # Tell the figure to save its data to the sink, using the
        # frame format and dpi.
        with self._frame_sink() as myframesink:
            self.fig.savefig(myframesink, format=self.frame_format,
                             dpi=self.dpi, **savefig_kwargs)

    def cleanup(self):
        # explictily skip a step in the mro
        ma.MovieWriter.cleanup(self)

should end up in the animation module in the case where people just want a folder of png and don't have any of the other external tools installed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good first issueOpen a pull request against these issues if there are no active ones!New featurestatus: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github Actiontopic: animation

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions