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

Method print_png

lib/matplotlib/backends/backend_agg.py:490–537  ·  view source on GitHub ↗

Write the figure to a PNG file. Parameters ---------- filename_or_obj : str or path-like or file-like The file to write to. metadata : dict, optional Metadata in the PNG file as key-value pairs of bytes or latin-1 encodab

(self, filename_or_obj, *, metadata=None, pil_kwargs=None)

Source from the content-addressed store, hash-verified

488 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
489
490 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
491 """
492 Write the figure to a PNG file.
493
494 Parameters
495 ----------
496 filename_or_obj : str or path-like or file-like
497 The file to write to.
498
499 metadata : dict, optional
500 Metadata in the PNG file as key-value pairs of bytes or latin-1
501 encodable strings.
502 According to the PNG specification, keys must be shorter than 79
503 chars.
504
505 The `PNG specification`_ defines some common keywords that may be
506 used as appropriate:
507
508 - Title: Short (one line) title or caption for image.
509 - Author: Name of image's creator.
510 - Description: Description of image (possibly long).
511 - Copyright: Copyright notice.
512 - Creation Time: Time of original image creation
513 (usually RFC 1123 format).
514 - Software: Software used to create the image.
515 - Disclaimer: Legal disclaimer.
516 - Warning: Warning of nature of content.
517 - Source: Device used to create the image.
518 - Comment: Miscellaneous comment;
519 conversion from other image format.
520
521 Other keywords may be invented for other purposes.
522
523 If 'Software' is not given, an autogenerated value for Matplotlib
524 will be used. This can be removed by setting it to *None*.
525
526 For more details see the `PNG specification`_.
527
528 .. _PNG specification: \
529 https://www.w3.org/TR/2003/REC-PNG-20031110/#11keywords
530
531 pil_kwargs : dict, optional
532 Keyword arguments passed to `PIL.Image.Image.save`.
533
534 If the 'pnginfo' key is present, it completely overrides
535 *metadata*, including the default 'Software' key.
536 """
537 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
538
539 def print_to_buffer(self):
540 FigureCanvasAgg.draw(self)

Callers

nothing calls this directly

Calls 1

_print_pilMethod · 0.95

Tested by

no test coverage detected