Please pardon me, but what object is math.usetex attribute of? I can't find
it in the documentation.
http://matplotlib.org/users/usetex.html Mentions only text.usetex.
2013/3/30 Phil Elson <pelson....@gmail.com>
> Doesn't look like you're using math.usetex & therefore are not actually
> using latex, but mpl's stripped down tex implementation.
>
> Try setting usetex to True, or alternatively I think you could use \mathrm
> instead of \text to get non mathematical text.
>
> HTH
>
>
> On 30 March 2013 11:43, Pawel Chojnacki <chojnacki.pa...@linux.com> wrote:
>
>> Hello,
>>
>> I've been having some troubles with LaTeX in matplotlib. My example
>> script:
>>
>> #!/usr/bin/env python2
>> #-*- coding: utf-8 -*-
>>
>> __author__ = 'Pawel Chojnacki'
>> __copyright__ ='Copyleft 2013 Pawel Chojnacki'
>> __version__ = '1.0'
>> __date__ = '29-03-2013'
>> __license__ = 'GPLv3'
>>
>> import numpy as np
>> import matplotlib as mpl # Zmiana ustawien LaTeXa
>> mpl.rcParams['text.latex.preamble'].append(r'\usepackage{amsmath}')
>> #~ mpl.rcParams['text.latex.preamble'] = r'\usepackage{amsmath}'
>> #~ mpl.rcParams['text.latex.preamble']=[r"\usepackage{amsmath}"]
>> #~ mpl.rcParams['math.usetex'] = True
>> print mpl.rcParams['text.latex.preamble']
>> import pylab as py
>>
>> py.axhspan(8400,8730,alpha=0.15)
>> py.title(u'Wyniki eksperymentu pomiaru gęstości ciała
>> stałego\n',size='large',family='serif')
>> py.ylabel((u'Gęstość ciała stałego ' +
>> r'$\frac{kg}{m^3}$'),size='large',family='serif')
>> #~ py.ylabel((r'$\text{lol}$'),size='large',family='serif')
>> py.ylabel((r'$\text{lol}$'),size='large',family='serif')
>> py.xlabel(u'Metoda pomiaru',size='large',family='serif')
>> py.grid(True)
>> py.show()
>>
>> Gives me the following output:
>>
>> ['', '\\usepackage{amsmath}']
>> Exception in Tkinter callback
>> Traceback (most recent call last):
>> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1437, in __call__
>> return self.func(*args)
>> File
>> "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line
>> 236, in resize
>> self.show()
>> File
>> "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line
>> 239, in draw
>> FigureCanvasAgg.draw(self)
>> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.py",
>> line 421, in draw
>> self.figure.draw(self.renderer)
>> File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55, in
>> draw_wrapper
>> draw(artist, renderer, *args, **kwargs)
>> File "/usr/lib/pymodules/python2.7/matplotlib/figure.py", line 898, in
>> draw
>> func(*args)
>> File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55, in
>> draw_wrapper
>> draw(artist, renderer, *args, **kwargs)
>> File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 1997, in
>> draw
>> a.draw(renderer)
>> File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55, in
>> draw_wrapper
>> draw(artist, renderer, *args, **kwargs)
>> File "/usr/lib/pymodules/python2.7/matplotlib/axis.py", line 1054, in
>> draw
>> self.label.draw(renderer)
>> File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55, in
>> draw_wrapper
>> draw(artist, renderer, *args, **kwargs)
>> File "/usr/lib/pymodules/python2.7/matplotlib/text.py", line 526, in
>> draw
>> bbox, info = self._get_layout(renderer)
>> File "/usr/lib/pymodules/python2.7/matplotlib/text.py", line 309, in
>> _get_layout
>> ismath=ismath)
>> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.py",
>> line 193, in get_text_width_height_descent
>> self.mathtext_parser.parse(s, self.dpi, prop)
>> File "/usr/lib/pymodules/python2.7/matplotlib/mathtext.py", line 2999,
>> in parse
>> box = self._parser.parse(s, font_output, fontsize, dpi)
>> File "/usr/lib/pymodules/python2.7/matplotlib/mathtext.py", line 2357,
>> in parse
>> self._expression.parseString(s)
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyparsing.py", line 1048,
>> in parseString
>> loc, tokens = self._parse( instring, 0 )
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyparsing.py", line 981,
>> in _parseCache
>> value = self._parseNoCache( instring, loc, doActions, callPreParse )
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyparsing.py", line 924,
>> in _parseNoCache
>> loc,tokens = self.parseImpl( instring, preloc, doActions )
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyparsing.py", line 2559,
>> in parseImpl
>> return self.expr._parse( instring, loc, doActions, callPreParse=False
>> )
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyparsing.py", line 981,
>> in _parseCache
>> value = self._parseNoCache( instring, loc, doActions, callPreParse )
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyparsing.py", line 924,
>> in _parseNoCache
>> loc,tokens = self.parseImpl( instring, preloc, doActions )
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyparsing.py", line 2307,
>> in parseImpl
>> loc, exprtokens = e._parse( instring, loc, doActions )
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyparsing.py", line 981,
>> in _parseCache
>> value = self._parseNoCache( instring, loc, doActions, callPreParse )
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyparsing.py", line 924,
>> in _parseNoCache
>> loc,tokens = self.parseImpl( instring, preloc, doActions )
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyparsing.py", line 2672,
>> in parseImpl
>> loc, tokens = self.expr._parse( instring, loc, doActions,
>> callPreParse=False )
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyparsing.py", line 981,
>> in _parseCache
>> value = self._parseNoCache( instring, loc, doActions, callPreParse )
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyparsing.py", line 924,
>> in _parseNoCache
>> loc,tokens = self.parseImpl( instring, preloc, doActions )
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyparsing.py", line 2307,
>> in parseImpl
>> loc, exprtokens = e._parse( instring, loc, doActions )
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyparsing.py", line 981,
>> in _parseCache
>> value = self._parseNoCache( instring, loc, doActions, callPreParse )
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyparsing.py", line 924,
>> in _parseNoCache
>> loc,tokens = self.parseImpl( instring, preloc, doActions )
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyparsing.py", line 2416,
>> in parseImpl
>> ret = e._parse( instring, loc, doActions )
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyparsing.py", line 981,
>> in _parseCache
>> value = self._parseNoCache( instring, loc, doActions, callPreParse )
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyparsing.py", line 950,
>> in _parseNoCache
>> tokens = fn( instring, tokensStart, retTokens )
>> File "/usr/lib/pymodules/python2.7/matplotlib/mathtext.py", line 2050,
>> in raise_error
>> raise ParseFatalException(msg + "\n" + s)
>> ParseFatalException: Expected end of math '$'
>> $\text{lol}$ (at char 0), (line:1, col:1)
>>
>> And a blank window. The same line - $\text{lol}$ works pretty well in
>> pure LaTeX. While the package seems loaded, matplotlib doesn't send the
>> command as it's supposed to. Why is that?
>>
>> Thanks in advance,
>>
>> Pawel
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Own the Future-Intel(R) Level Up Game Demo Contest 2013
>> Rise to greatness in Intel's independent game demo contest. Compete
>> for recognition, cash, and the chance to get your game on Steam.
>> $5K grand prize plus 10 genre and skill prizes. Submit your demo
>> by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2
>> _______________________________________________
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
------------------------------------------------------------------------------
Own the Future-Intel(R) Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest. Compete
for recognition, cash, and the chance to get your game on Steam.
$5K grand prize plus 10 genre and skill prizes. Submit your demo
by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users