SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Neal B. <ndb...@gm...> - 2013年12月07日 15:25:26
I'm using
import matplotlib as mpl
mpl.use ('pdf')
from matplotlib.backends.backend_pdf import PdfPages
...
 self.pdf = PdfPages(file_name)
...
 self.pdf.savefig (self.fig)
 plt.close()
...
pdf.close()
This works fine, but now I want to try pgf.
If I add:
from matplotlib.backends.backend_pgf import FigureCanvasPgf 
mpl.backend_bases.register_backend('pdf', FigureCanvasPgf) 
at the beginning, then it chokes on the savefig (self.fig):
Traceback (most recent call last):
 File "./plot_stuff2.py", line 362, in <module>
 the_plot.finish (args, opt, time, res)
 File "./plot_stuff2.py", line 157, in finish
 self.pdf.savefig (self.fig)
 File "/home/nbecker/.local/lib/python2.7/site-
packages/matplotlib/backends/backend_pdf.py", line 2297, in savefig
 figure.savefig(self, format='pdf', **kwargs)
 File "/home/nbecker/.local/lib/python2.7/site-packages/matplotlib/figure.py", 
line 1421, in savefig
 self.canvas.print_figure(*args, **kwargs)
 File "/home/nbecker/.local/lib/python2.7/site-
packages/matplotlib/backend_bases.py", line 2220, in print_figure
 **kwargs)
 File "/home/nbecker/.local/lib/python2.7/site-
packages/matplotlib/backend_bases.py", line 2060, in _print_method
 return print_method(*args, **kwargs)
 File "/home/nbecker/.local/lib/python2.7/site-
packages/matplotlib/backends/backend_pgf.py", line 869, in print_pdf
 raise ValueError("filename must be a path or a file-like object")
ValueError: filename must be a path or a file-like object
I know I had this working some time in the past, what's the trick to making 
multi-page pdf with pgf?
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /