Context manager to facilitate writing the movie file. ``*args, **kw`` are any parameters that should be passed to `setup`.
(self, fig, outfile, dpi, *args, **kwargs)
| 209 | |
| 210 | @contextlib.contextmanager |
| 211 | def saving(self, fig, outfile, dpi, *args, **kwargs): |
| 212 | """ |
| 213 | Context manager to facilitate writing the movie file. |
| 214 | |
| 215 | ``*args, **kw`` are any parameters that should be passed to `setup`. |
| 216 | """ |
| 217 | if mpl.rcParams['savefig.bbox'] == 'tight': |
| 218 | _log.info("Disabling savefig.bbox = 'tight', as it may cause " |
| 219 | "frame size to vary, which is inappropriate for " |
| 220 | "animation.") |
| 221 | |
| 222 | # This particular sequence is what contextlib.contextmanager wants |
| 223 | self.setup(fig, outfile, dpi, *args, **kwargs) |
| 224 | with mpl.rc_context({'savefig.bbox': None}): |
| 225 | try: |
| 226 | yield self |
| 227 | finally: |
| 228 | self.finish() |
| 229 | |
| 230 | |
| 231 | class MovieWriter(AbstractMovieWriter): |