Changeset 1646

Show
Ignore:
Timestamp:
02/25/10 15:06:58 (5 months ago)
Author:
joishi
Message:

ported new save_book from trunk to yt-1.6. this uses matplotlib's native PdfPages?, removing PyPdf? dependency

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/yt-1.6/yt/raven/PlotCollection.py

    r1620 r1646  
    462462 
    463463    @rootonly 
    464     def save_book(self, filename): 
    465         from pyPdf import PdfFileWriter, PdfFileReader 
    466         outfile = PdfFileWriter() 
    467         fns = self.save("__temp", format="pdf") 
    468         concatenate_pdfs(filename, fns) 
    469         for fn in fns: os.unlink(fn) 
     464    def save_book(self, filename, info = None): 
     465        """ 
     466        This will save out a single PDF, where each page is a plot object.  The 
     467        *info* keyword can be a dictionary composed of the keys and values 
     468        "Author", "Title", "Subject", "Keywords", "Creator", "Producer" ad 
     469        "CreationDate".  Any keywords not filled in will be blank.  The default 
     470        is to use the current settings in Matplotlib for filling them in. 
     471        """ 
     472        from matplotlib.backends.backend_pdf import PdfPages 
     473        outfile = PdfPages(filename) 
     474        for plot in self.plots: 
     475            plot.save_to_pdf(outfile) 
     476        if info is not None: 
     477            outfile._file.writeObject(outfile._file.infoObject, info) 
     478        outfile.close() 
    470479 
    471480def wrap_pylab_newplot(func):