@@ -410,7 +410,7 @@ def restore_region(self, region, bbox=None, xy=None):
410
410
411
411
def draw (self ):
412
412
"""
413
- Draw the figure using the renderer
413
+ Draw the figure using the renderer.
414
414
"""
415
415
self .renderer = self .get_renderer (cleared = True )
416
416
# acquire a lock on the shared font cache
@@ -440,7 +440,7 @@ def get_renderer(self, cleared=False):
440
440
return self .renderer
441
441
442
442
def tostring_rgb (self ):
443
- '''Get the image as an RGB byte string
443
+ '''Get the image as an RGB byte string.
444
444
445
445
`draw` must be called at least once before this function will work and
446
446
to update the renderer for any subsequent changes to the Figure.
@@ -465,7 +465,7 @@ def tostring_argb(self):
465
465
return self .renderer .tostring_argb ()
466
466
467
467
def buffer_rgba (self ):
468
- '''Get the image as an RGBA byte string
468
+ '''Get the image as an RGBA byte string.
469
469
470
470
`draw` must be called at least once before this function will work and
471
471
to update the renderer for any subsequent changes to the Figure.
@@ -485,6 +485,47 @@ def print_raw(self, filename_or_obj, *args, **kwargs):
485
485
print_rgba = print_raw
486
486
487
487
def print_png (self , filename_or_obj , * args , ** kwargs ):
488
+ """
489
+ Write the figure to a PNG file.
490
+
491
+ Parameters
492
+ ----------
493
+ filename_or_obj : str or PathLike or file-like object
494
+ The file to write to.
495
+
496
+ metadata : dict, optional
497
+ Metadata in the PNG file as key-value pairs of bytes or latin-1
498
+ encodable strings.
499
+ According to the PNG specification, keys must be shorter than 79
500
+ chars.
501
+
502
+ The `PNG specification`_ defines some common keywords that may be
503
+ used as appropriate:
504
+
505
+ - Title: Short (one line) title or caption for image.
506
+ - Author: Name of image's creator.
507
+ - Description: Description of image (possibly long).
508
+ - Copyright: Copyright notice.
509
+ - Creation Time: Time of original image creation
510
+ (usually RFC 1123 format).
511
+ - Software: Software used to create the image.
512
+ - Disclaimer: Legal disclaimer.
513
+ - Warning: Warning of nature of content.
514
+ - Source: Device used to create the image.
515
+ - Comment: Miscellaneous comment;
516
+ conversion from other image format.
517
+
518
+ Other keywords may be invented for other purposes.
519
+
520
+ If 'Software' is not given, an autogenerated value for matplotlib
521
+ will be used.
522
+
523
+ For more details see the `PNG specification`_.
524
+
525
+ .. _PNG specification: \
526
+ https://www.w3.org/TR/2003/REC-PNG-20031110/#11keywords
527
+
528
+ """
488
529
FigureCanvasAgg .draw (self )
489
530
renderer = self .get_renderer ()
490
531
@@ -511,6 +552,13 @@ def print_to_buffer(self):
511
552
# add JPEG support
512
553
def print_jpg (self , filename_or_obj , * args , dryrun = False , ** kwargs ):
513
554
"""
555
+ Write the figure to a JPEG file.
556
+
557
+ Parameters
558
+ ----------
559
+ filename_or_obj : str or PathLike or file-like object
560
+ The file to write to.
561
+
514
562
Other Parameters
515
563
----------------
516
564
quality : int
0 commit comments