osx - Python 3.3 + Matplotlib 1.2.0: pdf export generates "'str' does not support the buffer interface" error -


i started migrating matlab/mathematica python technical computing. have been learning how use matplotlib.pyplot package , hoping me fonts. need save graphical output pdf or eps files can open in adobe illustrator. initially, pdf , eps output contained outlined fonts (rather embedded fonts retaining text information). following this helpful advice, ended following code:

import matplotlib mpl import matplotlib.pyplot plt # if omit next line, plot saves without error, outlined fonts mpl.rcparams['pdf.fonttype'] = 42        #set truetype fonts adobe plt.plot(range(5),range(5),'r-') plt.ylabel('y') plt.xlabel('x') plt.title('title') plt.show() plt.savefig("myfig.pdf") 

however, when set rcparams['pdf.fonttype']=42, final line generates error copied below. can point me in right direction? running python 3.3 , matplotlib 1.2.0, using pyzo distribution on mac os 10.6.

traceback (most recent call last):   file "<tmp 1>", line 11, in <module> plt.savefig("myfig.pdf")   file "/applications/pyzo2013b/lib/python3.3/pyzo-packages/matplotlib/pyplot.py", line 472, in savefig     return fig.savefig(*args, **kwargs)    file "/applications/pyzo2013b/lib/python3.3/pyzo-packages/matplotlib/figure.py", line 1364, in savefig      self.canvas.print_figure(*args, **kwargs)   file "/applications/pyzo2013b/lib/python3.3/pyzo-packages/matplotlib/backends/backend_qt4agg.py", line 161, in print_figure     figurecanvasagg.print_figure(self, *args, **kwargs)   file "/applications/pyzo2013b/lib/python3.3/pyzo-packages/matplotlib/backend_bases.py", line 2093, in print_figure     **kwargs)   file "/applications/pyzo2013b/lib/python3.3/pyzo-packages/matplotlib/backend_bases.py", line 1845, in print_pdf     return pdf.print_pdf(*args, **kwargs)   file "/applications/pyzo2013b/lib/python3.3/pyzo-packages/matplotlib/backends/backend_pdf.py", line 2307, in print_pdf     file.close()   file "/applications/pyzo2013b/lib/python3.3/pyzo-packages/matplotlib/backends/backend_pdf.py", line 507, in close     self.writefonts()   file "/applications/pyzo2013b/lib/python3.3/pyzo-packages/matplotlib/backends/backend_pdf.py", line 607, in writefonts     fonts[fx] = self.embedttf(realpath, chars[1])   file "/applications/pyzo2013b/lib/python3.3/pyzo-packages/matplotlib/backends/backend_pdf.py", line 1054, in embedttf     return embedttftype42(font, characters, descriptor)   file "/applications/pyzo2013b/lib/python3.3/pyzo-packages/matplotlib/backends/backend_pdf.py", line 987, in embedttftype42     self.currentstream.write(unicode_cmap)   file "/applications/pyzo2013b/lib/python3.3/pyzo-packages/matplotlib/backends/backend_pdf.py", line 379, in write     compressed = self.compressobj.compress(data) typeerror: 'str' not support buffer interface 

this bug in matplotlib , fixed here: https://github.com/matplotlib/matplotlib/pull/1978#issuecomment-17493157


Comments