更新时间:2023-12-02 19:07:22
使用 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()