From: Damon M. <D.M...@wa...> - 2011-08-11 11:03:11
|
Hi, I am having a ridiculous amount of trouble getting Computer Modern Roman to appear in my plots. So many problems, in fact, I nuked the whole of macports and installed the things I need again because I thought it might have been a problem with using an upgraded version of macports from Snow Leopard (I'm now using Lion). This is what I have: OS X Lion Fresh install of python 2.6 from macports Numpy version 1.6.1 (from macports) freetype (from macports) libpng (from macports) matplotlib 1.0.1 (from macports) When I run my plotting script, I get the following error as soon as the script starts (i.e., right after matplotlib is imported): /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/__init__.py:403: UserWarning: matplotlibrc text.usetex can not be used with *Agg backend unless dvipng-1.5 or later is installed on your system warnings.warn( 'matplotlibrc text.usetex can not be used with *Agg ' Note: I am using the PDF backend. When I try to save the plot to a pdf file, I get the following error: /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py:1242: UserWarning: findfont: Font family ['serif'] not found. Falling back to Bitstream Vera Sans (prop.get_family(), self.defaultFamily[fontext])) This is frustrating because it's a serif font that I need. After much thought, and Googling, I found out how to suppress the first warning message, and that is to add the directory where dvipng lives to my PATH variable. It is worth noting here that dvipng version 1.5 does not exist. The latest version is 1.14 as can be seen here: http://download.savannah.gnu.org/releases/dvipng/ Once I do this the first warning message does not appear, and the font error disappears but I get a new error: Traceback (most recent call last): File "refinement.py", line 60, in <module> fig.savefig('conv.pdf') File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/figure.py", line 1084, in savefig self.canvas.print_figure(*args, **kwargs) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backend_bases.py", line 1923, in print_figure **kwargs) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/backend_pdf.py", line 2156, in print_pdf self.figure.draw(renderer) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/figure.py", line 798, in draw func(*args) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/axes.py", line 1946, in draw a.draw(renderer) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/axis.py", line 1017, in draw tick.draw(renderer) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/axis.py", line 234, in draw self.label1.draw(renderer) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/text.py", line 571, in draw self._fontproperties, angle) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/backend_pdf.py", line 1549, in draw_tex psfont = self.tex_font_mapping(dvifont.texname) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/backend_pdf.py", line 1365, in tex_font_mapping dviread.PsfontsMap(dviread.find_tex_file('pdftex.map')) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/dviread.py", line 668, in __init__ self._parse(file) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/dviread.py", line 701, in _parse self._register(words) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/dviread.py", line 727, in _register assert encoding is None AssertionError I have no idea what this means or how to fix it! I assumed it was a problem with the version of dvipng that I'm using, but I'm using the latest one. I have also tried grabbing the matplotlib source from git and compiling it by hand (yes, both the macports install and the source install see that I have latex installed, I also have type1cm.sty installed from texlive-latex-extra so the fonts are there. typ1cm.sty lives in /opt/local/share/texmf-texlive-dist/tex/latex/type1cm/). Maybe it's a problem with matplotlib not looking in the right place for the fonts? Can anybody out there provide any suggestions? Damon McDougall d.m...@wa... http://damon.is-a-geek.com B2.39 Mathematics Institute Coventry West Midlands CV4 7AL |