更新时间:2023-12-02 19:38:10
使用 PdfPages
来解决您的问题.将您的 figure
对象传递给 savefig
方法.
Use PdfPages
to solve your problem. Pass your figure
object to the savefig
method.
例如,如果您打开了一大堆 figure
对象,并且您想将它们保存到多页 PDF 中,您可以这样做:
For example, if you have a whole pile of figure
objects open and you want to save them into a multi-page PDF, you might do:
import matplotlib.backends.backend_pdf
pdf = matplotlib.backends.backend_pdf.PdfPages("output.pdf")
for fig in xrange(1, figure().number): ## will open an empty extra figure :(
pdf.savefig( fig )
pdf.close()