Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2f2f617

Browse files
authored
Merge pull request #16749 from anntzer/savefig-ext
DOC: Document behavior of savefig("extensionless-name").
2 parents 03af217 + ece71a0 commit 2f2f617

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

lib/matplotlib/figure.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,12 +2044,16 @@ def savefig(self, fname, *, transparent=None, **kwargs):
20442044
possibly some backend-dependent object such as
20452045
`matplotlib.backends.backend_pdf.PdfPages`.
20462046
2047-
If *format* is not set, then the output format is inferred from
2048-
the extension of *fname*, if any, and from :rc:`savefig.format`
2049-
otherwise. If *format* is set, it determines the output format.
2050-
2051-
Hence, if *fname* is not a path or has no extension, remember to
2052-
specify *format* to ensure that the correct backend is used.
2047+
If *format* is set, it determines the output format, and the file
2048+
is saved as *fname*. Note that *fname* is used verbatim, and there
2049+
is no attempt to make the extension, if any, of *fname* match
2050+
*format*, and no extension is appended.
2051+
2052+
If *format* is not set, then the format is inferred from the
2053+
extension of *fname*, if there is one. If *format* is not
2054+
set and *fname* has no extension, then the file is saved with
2055+
:rc:`savefig.format` and the appropriate extension is appended to
2056+
*fname*.
20532057
20542058
Other Parameters
20552059
----------------

0 commit comments

Comments
 (0)