Saves a :class:`~matplotlib.figure.Figure` to this file as a new page. Any other keyword arguments are passed to :meth:`~matplotlib.figure.Figure.savefig`. Parameters ---------- figure : :class:`~matplotlib.figure.Figure` or int, optional
(self, figure=None, **kwargs)
| 2477 | return self._file.infoDict |
| 2478 | |
| 2479 | def savefig(self, figure=None, **kwargs): |
| 2480 | """ |
| 2481 | Saves a :class:`~matplotlib.figure.Figure` to this file as a new page. |
| 2482 | |
| 2483 | Any other keyword arguments are passed to |
| 2484 | :meth:`~matplotlib.figure.Figure.savefig`. |
| 2485 | |
| 2486 | Parameters |
| 2487 | ---------- |
| 2488 | |
| 2489 | figure : :class:`~matplotlib.figure.Figure` or int, optional |
| 2490 | Specifies what figure is saved to file. If not specified, the |
| 2491 | active figure is saved. If a :class:`~matplotlib.figure.Figure` |
| 2492 | instance is provided, this figure is saved. If an int is specified, |
| 2493 | the figure instance to save is looked up by number. |
| 2494 | """ |
| 2495 | if not isinstance(figure, Figure): |
| 2496 | if figure is None: |
| 2497 | manager = Gcf.get_active() |
| 2498 | else: |
| 2499 | manager = Gcf.get_fig_manager(figure) |
| 2500 | if manager is None: |
| 2501 | raise ValueError("No figure {}".format(figure)) |
| 2502 | figure = manager.canvas.figure |
| 2503 | # Force use of pdf backend, as PdfPages is tightly coupled with it. |
| 2504 | try: |
| 2505 | orig_canvas = figure.canvas |
| 2506 | figure.canvas = FigureCanvasPdf(figure) |
| 2507 | figure.savefig(self, format="pdf", **kwargs) |
| 2508 | finally: |
| 2509 | figure.canvas = orig_canvas |
| 2510 | |
| 2511 | def get_pagecount(self): |
| 2512 | """ |
nothing calls this directly
no test coverage detected