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

Method print_png

lib/matplotlib/backends/backend_pgf.py:866–877  ·  view source on GitHub ↗

Use LaTeX to compile a pgf figure to pdf and convert it to png.

(self, fname_or_fh, **kwargs)

Source from the content-addressed store, hash-verified

864 shutil.copyfileobj(orig, dest) # copy file contents to target
865
866 def print_png(self, fname_or_fh, **kwargs):
867 """Use LaTeX to compile a pgf figure to pdf and convert it to png."""
868 converter = make_pdf_to_png_converter()
869 with TemporaryDirectory() as tmpdir:
870 tmppath = pathlib.Path(tmpdir)
871 pdf_path = tmppath / "figure.pdf"
872 png_path = tmppath / "figure.png"
873 self.print_pdf(pdf_path, **kwargs)
874 converter(pdf_path, png_path, dpi=self.figure.dpi)
875 with (png_path.open("rb") as orig,
876 cbook.open_file_cm(fname_or_fh, "wb") as dest):
877 shutil.copyfileobj(orig, dest) # copy file contents to target
878
879 def get_renderer(self):
880 return RendererPgf(self.figure, None)

Callers

nothing calls this directly

Calls 3

print_pdfMethod · 0.95
openMethod · 0.45

Tested by

no test coverage detected