Setup for writing the movie file. Parameters ---------- fig : `~matplotlib.figure.Figure` The figure to grab the rendered frames from. outfile : str The filename of the resulting movie file. dpi : float, default: ``fig.dpi``
(self, fig, outfile, dpi=None, frame_prefix=None)
| 386 | self.frame_format = mpl.rcParams['animation.frame_format'] |
| 387 | |
| 388 | def setup(self, fig, outfile, dpi=None, frame_prefix=None): |
| 389 | """ |
| 390 | Setup for writing the movie file. |
| 391 | |
| 392 | Parameters |
| 393 | ---------- |
| 394 | fig : `~matplotlib.figure.Figure` |
| 395 | The figure to grab the rendered frames from. |
| 396 | outfile : str |
| 397 | The filename of the resulting movie file. |
| 398 | dpi : float, default: ``fig.dpi`` |
| 399 | The dpi of the output file. This, with the figure size, |
| 400 | controls the size in pixels of the resulting movie file. |
| 401 | frame_prefix : str, optional |
| 402 | The filename prefix to use for temporary files. If *None* (the |
| 403 | default), files are written to a temporary directory which is |
| 404 | deleted by `finish`; if not *None*, no temporary files are |
| 405 | deleted. |
| 406 | """ |
| 407 | # Check that path is valid |
| 408 | Path(outfile).parent.resolve(strict=True) |
| 409 | self.fig = fig |
| 410 | self.outfile = outfile |
| 411 | if dpi is None: |
| 412 | dpi = self.fig.dpi |
| 413 | self.dpi = dpi |
| 414 | self._adjust_frame_size() |
| 415 | |
| 416 | if frame_prefix is None: |
| 417 | self._tmpdir = TemporaryDirectory() |
| 418 | self.temp_prefix = str(Path(self._tmpdir.name, 'tmp')) |
| 419 | else: |
| 420 | self._tmpdir = None |
| 421 | self.temp_prefix = frame_prefix |
| 422 | self._frame_counter = 0 # used for generating sequential file names |
| 423 | self._temp_paths = list() |
| 424 | self.fname_format_str = '%s%%07d.%s' |
| 425 | |
| 426 | def __del__(self): |
| 427 | if hasattr(self, '_tmpdir') and self._tmpdir: |
nothing calls this directly
no test coverage detected