Issue
In python (for one figure created in a GUI) I was able to save the figure under .jpg and also .pdf by either using:
plt.savefig(filename1 + '.pdf')
or
plt.savefig(filename1 + '.jpg')
Using one file I would like to save multiple figures in either .pdf or .jpg (just like its done in math lab). Can anybody please help with this?
Solution
Use PdfPages
to solve your problem. Pass your figure
object to the savefig
method.
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()
Answered By - Mind Mixer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.