|
From: Pål G. E. <pa...@gm...> - 2011-03-08 18:05:59
|
Hi I'm trying to make a plot as a pdf file (or any vector format) with LaTeX fonts. I can make it output the file using show, but not with savefig (unless it is raster graphics). My setup is Fedora 13 64 bit with the latest TexLive: texlive-2011-0.1.20110227.fc13.x86_64 and matplotlib from svn, revision 8988. I can run tex_demo.py as it is from http://matplotlib.sourceforge.net/users/usetex.html but is I change it such that instead of a png it outputs a pdf, like the example below, it crashes. I know there was a post on the mail liste a couple of days ago ( Bug in `dviread.py'), but I'm not sure if this is the same error, which it shouldn't be as I'm using the latest svn revision. Does anyone have the same problem? The example and debug output are shown below. Regards Pål Example (test.py): --------------------------- #!/usr/bin/env python import matplotlib matplotlib.use('Qt4Agg') from matplotlib import rc from numpy import arange, cos, pi from matplotlib.pyplot import figure, axes, plot, xlabel, ylabel, title, \ grid, savefig, show rc('text', usetex=True) rc('font', family='serif') figure(1, figsize=(6,4)) ax = axes([0.1, 0.1, 0.8, 0.7]) t = arange(0.0, 1.0+0.01, 0.01) s = cos(2*2*pi*t)+2 plot(t, s) xlabel(r'\textbf{time (s)}') ylabel(r'\textit{voltage (mV)}',fontsize=16) title(r"\TeX\ is Number $\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!", fontsize=16, color='r') grid(True) savefig('tex_demo.pdf') show() -------------------------- Debug output ------ python test.py --verbose-debug-annoying : $HOME=/home/gudrun/foo_bar CONFIGDIR=/home/gudrun/foo_bar/.matplotlib matplotlib data path /export/work/foo_bar/matplotlib/lib/matplotlib/mpl-data loaded rc file /export/work/foo_bar/matplotlib/lib/matplotlib/mpl-data/matplotlibrc matplotlib version 1.1.0svn verbose.level debug-annoying interactive is False units is False platform is linux2 loaded modules: ['numpy.lib._iotools', 'xml.sax.urlparse', 'distutils', 'matplotlib.errno', 'matplotlib.matplotlib', '_bisect', 'subprocess', 'gc', 'matplotlib.tempfile', 'distutils.sysconfig', 'ctypes._endian', 'encodings.encodings', 'matplotlib.colors', 'numpy.core.numerictypes', 'numpy.testing.sys', 'numpy.core.info', 'xml', 'numpy.fft.types', 'numpy.ma.operator', 'numpy.ma.cPickle', 'struct', 'numpy.random.info', 'tempfile', 'base64', 'numpy.linalg', 'matplotlib.threading', 'numpy.testing.operator', 'imp', 'numpy.testing', 'collections', 'numpy.core.umath', 'distutils.types', 'numpy.lib.numpy', 'numpy.core.scalarmath', 'functools', 'zipimport', 'string', 'matplotlib.subprocess', 'numpy.testing.os', 'matplotlib.locale', 'numpy.lib.arraysetops', 'numpy.testing.unittest', 'numpy.lib.math', 'encodings.utf_8', 'matplotlib.__future__', 'zope', 'numpy.testing.re', 'itertools', 'numpy.version', 'numpy.lib.re', 'distutils.re', 'ctypes.os', 'numpy.core.os', 'numpy.lib.type_check', 'httplib', 'numpy.lib.__builtin__', 'signal', 'numpy.lib.types', 'numpy.lib._datasource', 'random', 'numpy.ma.extras', 'token', 'numpy.fft.fftpack_lite', 'matplotlib.cbook', 'ctypes.ctypes', 'xml.sax.xmlreader', 'numpy.__builtin__', 'dis', 'distutils.version', 'cStringIO', 'numpy.ma.core', 'numpy.numpy', 'matplotlib.StringIO', 'locale', 'numpy.add_newdocs', 'numpy.lib.getlimits', 'matplotlib.urllib2', 'syslog', 'xml.sax.saxutils', 'matplotlib.numpy', 'numpy.lib.sys', 'encodings', 'numpy.ma.itertools', 'StringIO', 'numpy.lib.io', 'abc', 'numpy.ctypes', 'numpy.testing.decorators', 'matplotlib.warnings', 'rfc822', 'matplotlib.string', 'urllib', 'matplotlib.sys', 're', 'numpy.lib._compiled_base', 'threading', 'new', 'numpy.random.mtrand', 'urllib2', 'matplotlib.cPickle', 'math', 'numpy.fft.helper', 'fcntl', 'numpy.ma.warnings', 'inspect', 'numpy.ma.inspect', 'UserDict', 'numpy.lib.function_base', 'distutils.os', 'matplotlib', 'numpy.fft.numpy', 'xml.sax.codecs', 'exceptions', 'numpy.lib.info', 'ctypes', 'numpy.lib.warnings', 'ctypes.struct', 'codecs', 'numpy.core._sort', 'numpy.os', 'paste', '_functools', '_locale', 'matplotlib.sre_constants', 'socket', 'thread', 'numpy.lib.ufunclike', 'numpy.core.memmap', 'traceback', 'numpy.core._dotblas', 'weakref', 'numpy.core._internal', 'numpy.fft.fftpack', 'opcode', 'numpy.linalg.lapack_lite', 'distutils.sys', 'os', 'marshal', 'numpy.lib.itertools', '__future__', 'matplotlib.copy', 'xml.sax.types', 'matplotlib.traceback', '_sre', 'unittest', 'numpy.core.sys', 'numpy.random', 'numpy.linalg.numpy', '__builtin__', 'numpy.lib.twodim_base', 'matplotlib.re', 'numpy.core.cPickle', 'operator', 'array', 'numpy.core.arrayprint', 'distutils.string', 'numpy.lib.arrayterator', 'select', 'ctypes._ctypes', 'ctypes.sys', 'matplotlib.datetime', 'posixpath', 'numpy.lib.financial', 'numpy.core.multiarray', 'errno', '_socket', 'binascii', 'sre_constants', 'datetime', 'numpy.ma', 'xml.sax.handler', 'os.path', 'tokenize', 'numpy.lib.stride_tricks', 'numpy.core.numpy', 'numpy', '_warnings', 'matplotlib.types', 'numpy.core.defmatrix', 'xml.sax.os', 'cPickle', 'encodings.__builtin__', 'matplotlib.xml', 'matplotlib.new', '_codecs', 'numpy.lib.operator', 'numpy.__config__', '_collections', 'matplotlib.pyparsing', 'numpy.ma.numpy', 'copy', 'numpy.core.re', '_struct', 'numpy.core.fromnumeric', 'hashlib', 'numpy.ctypeslib', 'keyword', 'numpy.lib.scimath', 'numpy.fft', 'numpy.lib', 'bisect', 'numpy.random.numpy', 'matplotlib.random', 'posix', 'encodings.aliases', 'matplotlib.fontconfig_pattern', 'fnmatch', 'sre_parse', 'abrt_exception_handler', 'pickle', 'numpy.core.ctypes', 'mimetools', 'distutils.distutils', 'copy_reg', 'sre_compile', 'xml.sax', '_hashlib', '_random', 'numpy.lib.__future__', 'site', 'numpy.lib.polynomial', 'numpy._import_tools', '__main__', 'numpy.fft.info', 'numpy.core.records', 'shutil', 'numpy.lib.cPickle', 'numpy.sys', 'matplotlib.weakref', 'xml.sax.urllib', 'matplotlib.os', 'numpy.testing.traceback', 'strop', 'numpy.testing.numpytest', 'numpy.core.numeric', 'numpy.linalg.info', 'encodings.codecs', '_abcoll', 'numpy.core', 'matplotlib.rcsetup', 'matplotlib.time', 'xml.sax._exceptions', 'genericpath', 'stat', '_ssl', 'numpy.lib.index_tricks', 'warnings', 'numpy.lib.utils', 'numpy.core.defchararray', '_ctypes', 'numpy.lib.shape_base', 'numpy.core.types', 'textwrap', 'sys', 'numpy.core.warnings', 'numpy.core.__builtin__', 'xml.sax.sys', 'numpy.lib.format', 'numpy.lib.os', 'numpy.testing.nosetester', 'types', 'numpy.lib.shutil', 'ssl', 'matplotlib.distutils', '_weakref', 'distutils.errors', 'urlparse', 'linecache', 'matplotlib.shutil', 'numpy.lib.cStringIO', 'time', 'numpy.lib.machar', 'numpy.linalg.linalg', 'numpy.testing.utils'] Using fontManager instance from /home/gudrun/foo_bar/.matplotlib/fontList.cache backend Qt4Agg version 0.9.1 Dvi: /home/gudrun/foo_bar/.matplotlib/tex.cache/03e7a0bce05f84219ebbd9b25349b054.dvi Dvi._xxx: encountered special: papersize=5203.43999pt,5203.43999pt find_tex_file(pncr7t.tfm): ['kpsewhich', 'pncr7t.tfm'] find_tex_file result: /usr/share/texlive/texmf-dist/fonts/tfm/adobe/ncntrsbk/pncr7t.tfm opening tfm file /usr/share/texlive/texmf-dist/fonts/tfm/adobe/ncntrsbk/pncr7t.tfm lh=18, bc=0, ec=170, nw=33, nh=16, nd=16 find_tex_file(pncr7t.vf): ['kpsewhich', 'pncr7t.vf'] find_tex_file result: /usr/share/texlive/texmf-dist/fonts/vf/adobe/ncntrsbk/pncr7t.vf Dvi: /usr/share/texlive/texmf-dist/fonts/vf/adobe/ncntrsbk/pncr7t.vf find_tex_file(pncr8r.tfm): ['kpsewhich', 'pncr8r.tfm'] find_tex_file result: /usr/share/texlive/texmf-dist/fonts/tfm/adobe/ncntrsbk/pncr8r.tfm opening tfm file /usr/share/texlive/texmf-dist/fonts/tfm/adobe/ncntrsbk/pncr8r.tfm lh=18, bc=1, ec=255, nw=38, nh=16, nd=16 find_tex_file(pncr8r.vf): ['kpsewhich', 'pncr8r.vf'] find_tex_file result: Dvi._xxx: encountered special: Warning: missing glyph `Gamma' Dvi._xxx: encountered special: Warning: missing glyph `Delta' Dvi._xxx: encountered special: Warning: missing glyph `Theta' Dvi._xxx: encountered special: Warning: missing glyph `Lambda' Dvi._xxx: encountered special: Warning: missing glyph `Xi' Dvi._xxx: encountered special: Warning: missing glyph `Pi' Dvi._xxx: encountered special: Warning: missing glyph `Sigma' Dvi._xxx: encountered special: Warning: missing glyph `Upsilon' Dvi._xxx: encountered special: Warning: missing glyph `Phi' Dvi._xxx: encountered special: Warning: missing glyph `Psi' Dvi._xxx: encountered special: Warning: missing glyph `Omega' Dvi._xxx: encountered special: Warning: missing glyph `dotlessj' Dvi._xxx: encountered special: Warning: missing glyph `lslashslash' Dvi: /home/gudrun/foo_bar/.matplotlib/tex.cache/3751fe08829ac873c509bb548895020f.dvi Dvi._xxx: encountered special: papersize=5203.43999pt,5203.43999pt find_tex_file(cmr12.tfm): ['kpsewhich', 'cmr12.tfm'] find_tex_file result: /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmr12.tfm opening tfm file /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmr12.tfm lh=18, bc=0, ec=127, nw=34, nh=16, nd=10 find_tex_file(cmr12.vf): ['kpsewhich', 'cmr12.vf'] find_tex_file result: find_tex_file(cmmi12.tfm): ['kpsewhich', 'cmmi12.tfm'] find_tex_file result: /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmmi12.tfm opening tfm file /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmmi12.tfm lh=18, bc=0, ec=127, nw=97, nh=15, nd=9 find_tex_file(cmmi12.vf): ['kpsewhich', 'cmmi12.vf'] find_tex_file result: Dvi: /home/gudrun/foo_bar/.matplotlib/tex.cache/3751fe08829ac873c509bb548895020f.dvi Dvi._xxx: encountered special: papersize=5203.43999pt,5203.43999pt Assigning font /F1 = cmr12 find_tex_file(pdftex.map): ['kpsewhich', 'pdftex.map'] find_tex_file result: /usr/share/texlive/texmf-var/fonts/map/pdftex/updmap/pdftex.map Multiple encodings for pbkdo8y = URWBookmanL-DemiBold, skipping Traceback (most recent call last): File "test", line 35, in <module> savefig('tex_demo.pdf') File "/export/work/foo_bar/matplotlib/lib/matplotlib/pyplot.py", line 363, in savefig return fig.savefig(*args, **kwargs) File "/export/work/foo_bar/matplotlib/lib/matplotlib/figure.py", line 1159, in savefig self.canvas.print_figure(*args, **kwargs) File "/export/work/foo_bar/matplotlib/lib/matplotlib/backends/backend_qt4agg.py", line 153, in print_figure FigureCanvasAgg.print_figure(self, *args, **kwargs) File "/export/work/foo_bar/matplotlib/lib/matplotlib/backend_bases.py", line 1963, in print_figure **kwargs) File "/export/work/foo_bar/matplotlib/lib/matplotlib/backend_bases.py", line 1737, in print_pdf return pdf.print_pdf(*args, **kwargs) File "/export/work/foo_bar/matplotlib/lib/matplotlib/backends/backend_pdf.py", line 2183, in print_pdf self.figure.draw(renderer) File "/export/work/foo_bar/matplotlib/lib/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File "/export/work/foo_bar/matplotlib/lib/matplotlib/figure.py", line 873, in draw func(*args) File "/export/work/foo_bar/matplotlib/lib/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File "/export/work/foo_bar/matplotlib/lib/matplotlib/axes.py", line 1954, in draw a.draw(renderer) File "/export/work/foo_bar/matplotlib/lib/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File "/export/work/foo_bar/matplotlib/lib/matplotlib/axis.py", line 986, in draw tick.draw(renderer) File "/export/work/foo_bar/matplotlib/lib/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File "/export/work/foo_bar/matplotlib/lib/matplotlib/axis.py", line 234, in draw self.label1.draw(renderer) File "/export/work/foo_bar/matplotlib/lib/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File "/export/work/foo_bar/matplotlib/lib/matplotlib/text.py", line 571, in draw self._fontproperties, angle) File "/export/work/foo_bar/matplotlib/lib/matplotlib/backends/backend_pdf.py", line 1576, in draw_tex psfont = self.tex_font_mapping(dvifont.texname) File "/export/work/foo_bar/matplotlib/lib/matplotlib/backends/backend_pdf.py", line 1366, in tex_font_mapping return self.tex_font_map[texfont] File "/export/work/foo_bar/matplotlib/lib/matplotlib/dviread.py", line 673, in __getitem__ result = self._font[texname] KeyError: 'cmr12' |