MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / savefig

Method savefig

lib/matplotlib/backends/backend_pgf.py:982–1016  ·  view source on GitHub ↗

Save a `.Figure` to this file as a new page. Any other keyword arguments are passed to `~.Figure.savefig`. Parameters ---------- figure : `.Figure` or int, default: the active figure The figure, or index of the figure, that is saved to the file.

(self, figure=None, **kwargs)

Source from the content-addressed store, hash-verified

980 shutil.move(tex_source.with_suffix(".pdf"), self._output_name)
981
982 def savefig(self, figure=None, **kwargs):
983 """
984 Save a `.Figure` to this file as a new page.
985
986 Any other keyword arguments are passed to `~.Figure.savefig`.
987
988 Parameters
989 ----------
990 figure : `.Figure` or int, default: the active figure
991 The figure, or index of the figure, that is saved to the file.
992 """
993 if not isinstance(figure, Figure):
994 if figure is None:
995 manager = Gcf.get_active()
996 else:
997 manager = Gcf.get_fig_manager(figure)
998 if manager is None:
999 raise ValueError(f"No figure {figure}")
1000 figure = manager.canvas.figure
1001
1002 width, height = figure.get_size_inches()
1003 if self._n_figures == 0:
1004 self._write_header(width, height)
1005 else:
1006 # \pdfpagewidth and \pdfpageheight exist on pdftex, xetex, and
1007 # luatex<0.85; they were renamed to \pagewidth and \pageheight
1008 # on luatex>=0.85.
1009 self._file.write(
1010 rb'\newpage'
1011 rb'\ifdefined\pdfpagewidth\pdfpagewidth\else\pagewidth\fi=%fin'
1012 rb'\ifdefined\pdfpageheight\pdfpageheight\else\pageheight\fi=%fin'
1013 b'%%\n' % (width, height)
1014 )
1015 figure.savefig(self._file, format="pgf", backend="pgf", **kwargs)
1016 self._n_figures += 1
1017
1018 def get_pagecount(self):
1019 """Return the current number of pages in the multipage pdf file."""

Callers 15

render_figuresFunction · 0.45
save_figureMethod · 0.45
save_figureMethod · 0.45
save_figureMethod · 0.45
save_figureMethod · 0.45
getMethod · 0.45
save_figureMethod · 0.45
on_responseMethod · 0.45
test_parent_axes_removalFunction · 0.45
test_visibilityFunction · 0.45
test_text_urlsFunction · 0.45

Calls 5

_write_headerMethod · 0.95
get_fig_managerMethod · 0.80
get_size_inchesMethod · 0.80
get_activeMethod · 0.45
writeMethod · 0.45

Tested by 15

test_parent_axes_removalFunction · 0.36
test_visibilityFunction · 0.36
test_text_urlsFunction · 0.36
count_tagFunction · 0.36
test_gidFunction · 0.36
test_clip_path_ids_reuseFunction · 0.36
test_savefig_tightFunction · 0.36
test_urlFunction · 0.36
test_url_tickFunction · 0.36