[Yt-svn] yt-commit r1646 - branches/yt-1.6/yt/raven
joishi at wrangler.dreamhost.com
joishi at wrangler.dreamhost.com
Thu Feb 25 15:06:59 PST 2010
Author: joishi
Date: Thu Feb 25 15:06:58 2010
New Revision: 1646
URL: http://yt.enzotools.org/changeset/1646
Log:
ported new save_book from trunk to yt-1.6. this uses matplotlib's native PdfPages, removing PyPdf dependency
Modified:
branches/yt-1.6/yt/raven/PlotCollection.py
Modified: branches/yt-1.6/yt/raven/PlotCollection.py
==============================================================================
--- branches/yt-1.6/yt/raven/PlotCollection.py (original)
+++ branches/yt-1.6/yt/raven/PlotCollection.py Thu Feb 25 15:06:58 2010
@@ -461,12 +461,21 @@
del self.plots[-1]
@rootonly
- def save_book(self, filename):
- from pyPdf import PdfFileWriter, PdfFileReader
- outfile = PdfFileWriter()
- fns = self.save("__temp", format="pdf")
- concatenate_pdfs(filename, fns)
- for fn in fns: os.unlink(fn)
+ def save_book(self, filename, info = None):
+ """
+ This will save out a single PDF, where each page is a plot object. The
+ *info* keyword can be a dictionary composed of the keys and values
+ "Author", "Title", "Subject", "Keywords", "Creator", "Producer" ad
+ "CreationDate". Any keywords not filled in will be blank. The default
+ is to use the current settings in Matplotlib for filling them in.
+ """
+ from matplotlib.backends.backend_pdf import PdfPages
+ outfile = PdfPages(filename)
+ for plot in self.plots:
+ plot.save_to_pdf(outfile)
+ if info is not None:
+ outfile._file.writeObject(outfile._file.infoObject, info)
+ outfile.close()
def wrap_pylab_newplot(func):
@wraps(func)
More information about the yt-svn
mailing list