[SciPy-user] Matplotlib improper rendering of latex

Marian Jakubik mjakubik at ta3.sk
Fri Mar 14 02:44:12 EDT 2008


Hello,

the title of your figure will be correct using this:

...
title(r'$y=2 sin(2\pi(x-\pi/4))$')
...

Best,
Marian


Dňa Thu, 13 Mar 2008 23:32:07 -0700
David Arnold <dwarnold45 at suddenlink.net> napísal:

> All,
> 
> I have:
> 
> #! /usr/local/bin/python
> 
> from pylab import *
> 	
> x=arange(0,2,0.01)
> y=2*sin(2*pi*(x-pi/4))
> 
> plot(x,y)
> xlabel('x-axis')
> ylabel('y-axis')
> title(r'$y=2\sin (2\pi(x-\pi/4))$')
> 
> show()
> 
> Running gives me this error:
> 
> code $ python simple.py --verbose-helpful
> matplotlib data path /Library/Frameworks/Python.framework/Versions/ 
> 2.5/lib/python2.5/site-packages/matplotlib/mpl-data
> $HOME=/Users/darnold
> CONFIGDIR=/Users/darnold/.matplotlib
> loaded rc file /Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/mpl-data/matplotlibrc
> matplotlib version 0.90.1
> verbose.level helpful
> interactive is False
> units is True
> platform is darwin
> numerix numpy 1.0.4
> font search path ['/Library/Frameworks/Python.framework/Versions/2.5/ 
> lib/python2.5/site-packages/matplotlib/mpl-data/fonts/ttf', '/Library/ 
> Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/ 
> matplotlib/mpl-data/fonts/afm']
> loaded ttfcache file /Users/darnold/.matplotlib/ttffont.cache
> backend TkAgg version 8.4
> Could not match Bitstream Vera Serif, New Century Schoolbook, Century  
> Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times  
> New Roman, Times, Palatino, Charter, serif, normal, normal.   
> Returning /Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
> Could not match Bitstream Vera Serif, New Century Schoolbook, Century  
> Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times  
> New Roman, Times, Palatino, Charter, serif, normal, normal.   
> Returning /Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
> Exception in Tkinter callback
> Traceback (most recent call last):
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/lib-tk/Tkinter.py", line 1403, in __call__
>      return self.func(*args)
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/backends/backend_tkagg.py", line  
> 151, in resize
>      self.show()
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/backends/backend_tkagg.py", line  
> 154, in draw
>      FigureCanvasAgg.draw(self)
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/backends/backend_agg.py", line  
> 392, in draw
>      self.figure.draw(renderer)
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/figure.py", line 601, in draw
>      for a in self.axes: a.draw(renderer)
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/axes.py", line 1286, in draw
>      a.draw(renderer)
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/text.py", line 410, in draw
>      bbox, info = self._get_layout(renderer)
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/text.py", line 255, in _get_layout
>      line, self._fontproperties, ismath=self.is_math_text())
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/backends/backend_agg.py", line  
> 246, in get_text_width_height
>      s, self.dpi.get(), prop.get_size_in_points())
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/mathtext.py", line 1587, in __call__
>      handler.expr.set_size_info(fontsize, dpi)
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/mathtext.py", line 1203, in  
> set_size_info
>      self.elements[0].set_size_info(self._scale*fontsize, dpi)
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/mathtext.py", line 1114, in  
> set_size_info
>      Element.set_size_info(self, fontsize, dpi)
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/mathtext.py", line 1027, in  
> set_size_info
>      element.set_size_info(self.fontsize, dpi)
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/mathtext.py", line 1114, in  
> set_size_info
>      Element.set_size_info(self, fontsize, dpi)
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/mathtext.py", line 1027, in  
> set_size_info
>      element.set_size_info(self.fontsize, dpi)
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/mathtext.py", line 1114, in  
> set_size_info
>      Element.set_size_info(self, fontsize, dpi)
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/mathtext.py", line 1027, in  
> set_size_info
>      element.set_size_info(self.fontsize, dpi)
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/mathtext.py", line 1116, in  
> set_size_info
>      self.font, self.sym, self.fontsize, dpi)
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/mathtext.py", line 597, in  
> get_metrics
>      self._get_info(font, sym, fontsize, dpi)
>    File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/site-packages/matplotlib/mathtext.py", line 616, in _get_info
>      raise ValueError('unrecognized symbol "%s"' % sym)
> ValueError: unrecognized symbol "\sin"
> 
> 
> 
> 
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user



More information about the SciPy-User mailing list