|
From: Pawel C. <cho...@li...> - 2013-03-30 11:43:42
|
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
|
|
From: Phil E. <pel...@gm...> - 2013-03-30 14:48:06
|
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 <cho...@li...> 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
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
|
|
From: Pawel C. <cho...@li...> - 2013-03-30 15:29:27
|
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 <pel...@gm...> > 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 <cho...@li...> 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 >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> > |
|
From: Juergen H. <py...@el...> - 2013-03-30 17:37:25
|
Am 30.03.2013 16:29, schrieb Pawel Chojnacki: > 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. > > You need to set mpl.rcParams['text.usetex'] = True For text you need unicode, for latex raw encoding. To have text and latex in one line, use xlabel(u'Häallo '+r'$\varphi$'+ 'r') Works for me, at least. |
|
From: Pawel C. <cho...@li...> - 2013-03-30 21:15:54
|
2013/3/30 Juergen Hasch <py...@el...> > Am 30.03.2013 16:29, schrieb Pawel Chojnacki: > > 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. > > > > > > You need to set > mpl.rcParams['text.usetex'] = True > > For text you need unicode, for latex raw encoding. > To have text and latex in one line, use > xlabel(u'Häallo '+r'$\varphi$'+ 'r') > > Works for me, at least. > I've already tried that, and I got the response: ['', '\\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/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 188, in get_text_width_height_descent renderer=self) File "/usr/lib/pymodules/python2.7/matplotlib/texmanager.py", line 606, in get_text_width_height_descent dvifile = self.make_dvi(tex, fontsize) File "/usr/lib/pymodules/python2.7/matplotlib/texmanager.py", line 351, in make_dvi texfile = self.make_tex(tex, fontsize) File "/usr/lib/pymodules/python2.7/matplotlib/texmanager.py", line 259, in make_tex fh.write(s) UnicodeEncodeError: 'ascii' codec can't encode character u'\u0119' in position 349: ordinal not in range(128) And after adding: mpl.rcParams['text.latex.preamble'].append(r'\usepackage{amsmath},\usepackage[utf8]{inputenc}') I got: ['', '\\usepackage{amsmath},\\usepackage[utf8]{inputenc}'] 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 1042, in draw ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw, renderer) File "/usr/lib/pymodules/python2.7/matplotlib/axis.py", line 993, in _get_tick_bboxes extent = tick.label1.get_window_extent(renderer) File "/usr/lib/pymodules/python2.7/matplotlib/text.py", line 747, in get_window_extent bbox, info = self._get_layout(self._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 188, in get_text_width_height_descent renderer=self) File "/usr/lib/pymodules/python2.7/matplotlib/texmanager.py", line 606, in get_text_width_height_descent dvifile = self.make_dvi(tex, fontsize) File "/usr/lib/pymodules/python2.7/matplotlib/texmanager.py", line 371, in make_dvi string:\n%s\nHere is the full report generated by LaTeX: \n\n'% repr(tex)) + report) RuntimeError: LaTeX was not able to process the following string: '$0.2$' Here is the full report generated by LaTeX: This is pdfTeX, Version 3.1415926-2.4-1.40.13 (TeX Live 2012/Debian) restricted \write18 enabled. entering extended mode (./d9d8962c45871ca6b62e5d3dffbe49ab.tex LaTeX2e <2011/06/27> Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, po lish, loaded. (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls Document Class: article 2007/10/19 v1.4h Standard LaTeX document class (/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo)) (/usr/share/texlive/texmf-dist/tex/latex/type1cm/type1cm.sty) (/usr/share/texlive/texmf-dist/tex/latex/psnfss/helvet.sty (/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)) (/usr/share/texlive/texmf-dist/tex/latex/psnfss/courier.sty) (/usr/share/texlive/texmf-dist/tex/latex/base/textcomp.sty (/usr/share/texlive/texmf-dist/tex/latex/base/ts1enc.def)) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty For additional information on amsmath, use the `?' option. (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty)) ! LaTeX Error: Missing \begin{document}. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.9 \usepackage{amsmath}, \usepackage[utf8]{inputenc} (/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty (/usr/share/texlive/texmf-dist/tex/latex/base/utf8.def (/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.dfu) (/usr/share/texlive/texmf-dist/tex/latex/base/ot1enc.dfu) (/usr/share/texlive/texmf-dist/tex/latex/base/omsenc.dfu) (/usr/share/texlive/texmf-dist/tex/latex/base/ts1enc.dfu))) (/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty) (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty) (/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty) Package geometry Warning: Over-specification in `h'-direction. `width' (5058.9pt) is ignored. Package geometry Warning: Over-specification in `v'-direction. `height' (5058.9pt) is ignored. ) No file d9d8962c45871ca6b62e5d3dffbe49ab.aux. (/usr/share/texlive/texmf-dist/tex/latex/base/ts1cmr.fd) (/usr/share/texlive/texmf-dist/tex/latex/psnfss/ot1pnc.fd) *geometry* driver: auto-detecting *geometry* detected driver: dvips (/usr/share/texlive/texmf-dist/tex/latex/psnfss/ot1phv.fd) [1] (./d9d8962c45871ca6b62e5d3dffbe49ab.aux) ) (see the transcript file for additional information) Output written on d9d8962c45871ca6b62e5d3dffbe49ab.dvi (1 page, 340 bytes). Transcript written on d9d8962c45871ca6b62e5d3dffbe49ab.log. And I really don't get what's happening :S |
|
From: Juergen H. <py...@el...> - 2013-03-30 23:49:09
|
I tested it under Linux now, and I see your problem. The latex files don't compile cleanly, this is why you get the
error. You can find the .tex files under ~./matplotlib/tex.cache
It looks like you have a problem with the font encoding when using unicode characters.
This works for me under Linux and Windows:
import numpy as np
import matplotlib as mpl
mpl.rcParams['text.latex.preamble'] = [r'\usepackage{amsmath}' , r'\usepackage[T1]{fontenc}']
mpl.rcParams['text.latex.unicode'] = True
mpl.rcParams['text.usetex'] = True
import pylab as py
py.axhspan(8400,8730,alpha=0.15)
py.title(u'Wyniki eksperymentu pomiaru gęstości ciała stałego',size='large',family='serif')
py.ylabel(r'$\text{lol}$',size='large',family='serif')
py.grid(True)
py.show()
Am 30.03.2013 22:15, schrieb Pawel Chojnacki:
> 2013/3/30 Juergen Hasch <py...@el... <mailto:py...@el...>>
>
> Am 30.03.2013 16:29, schrieb Pawel Chojnacki:
> > 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.
> >
> >
>
> You need to set
> mpl.rcParams['text.usetex'] = True
>
> For text you need unicode, for latex raw encoding.
> To have text and latex in one line, use
> xlabel(u'Häallo '+r'$\varphi$'+ 'r')
>
> Works for me, at least.
>
>
> I've already tried that, and I got the response:
>
> ['', '\\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/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 188, in get_text_width_height_descent
> renderer=self)
> File "/usr/lib/pymodules/python2.7/matplotlib/texmanager.py", line 606, in get_text_width_height_descent
> dvifile = self.make_dvi(tex, fontsize)
> File "/usr/lib/pymodules/python2.7/matplotlib/texmanager.py", line 351, in make_dvi
> texfile = self.make_tex(tex, fontsize)
> File "/usr/lib/pymodules/python2.7/matplotlib/texmanager.py", line 259, in make_tex
> fh.write(s)
> UnicodeEncodeError: 'ascii' codec can't encode character u'\u0119' in position 349: ordinal not in range(128)
>
> And after adding:
> mpl.rcParams['text.latex.preamble'].append(r'\usepackage{amsmath},\usepackage[utf8]{inputenc}')
> I got:
>
> ['', '\\usepackage{amsmath},\\usepackage[utf8]{inputenc}']
> 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 1042, in draw
> ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw, renderer)
> File "/usr/lib/pymodules/python2.7/matplotlib/axis.py", line 993, in _get_tick_bboxes
> extent = tick.label1.get_window_extent(renderer)
> File "/usr/lib/pymodules/python2.7/matplotlib/text.py", line 747, in get_window_extent
> bbox, info = self._get_layout(self._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 188, in get_text_width_height_descent
> renderer=self)
> File "/usr/lib/pymodules/python2.7/matplotlib/texmanager.py", line 606, in get_text_width_height_descent
> dvifile = self.make_dvi(tex, fontsize)
> File "/usr/lib/pymodules/python2.7/matplotlib/texmanager.py", line 371, in make_dvi
> string:\n%s\nHere is the full report generated by LaTeX: \n\n'% repr(tex)) + report)
> RuntimeError: LaTeX was not able to process the following string:
> '$0.2$'
> Here is the full report generated by LaTeX:
>
> This is pdfTeX, Version 3.1415926-2.4-1.40.13 (TeX Live 2012/Debian)
> restricted \write18 enabled.
> entering extended mode
> (./d9d8962c45871ca6b62e5d3dffbe49ab.tex
> LaTeX2e <2011/06/27>
> Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, po
> lish, loaded.
> (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
> Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
> (/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
> (/usr/share/texlive/texmf-dist/tex/latex/type1cm/type1cm.sty)
> (/usr/share/texlive/texmf-dist/tex/latex/psnfss/helvet.sty
> (/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty))
> (/usr/share/texlive/texmf-dist/tex/latex/psnfss/courier.sty)
> (/usr/share/texlive/texmf-dist/tex/latex/base/textcomp.sty
> (/usr/share/texlive/texmf-dist/tex/latex/base/ts1enc.def))
> (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty
> For additional information on amsmath, use the `?' option.
> (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty
> (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty))
> (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty)
> (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty))
>
> ! LaTeX Error: Missing \begin{document}.
>
> See the LaTeX manual or LaTeX Companion for explanation.
> Type H <return> for immediate help.
> ...
>
> l.9 \usepackage{amsmath},
> \usepackage[utf8]{inputenc}
> (/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty
> (/usr/share/texlive/texmf-dist/tex/latex/base/utf8.def
> (/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.dfu)
> (/usr/share/texlive/texmf-dist/tex/latex/base/ot1enc.dfu)
> (/usr/share/texlive/texmf-dist/tex/latex/base/omsenc.dfu)
> (/usr/share/texlive/texmf-dist/tex/latex/base/ts1enc.dfu)))
> (/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
> (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
> (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
> (/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
>
> Package geometry Warning: Over-specification in `h'-direction.
> `width' (5058.9pt) is ignored.
>
>
> Package geometry Warning: Over-specification in `v'-direction.
> `height' (5058.9pt) is ignored.
>
> )
> No file d9d8962c45871ca6b62e5d3dffbe49ab.aux.
> (/usr/share/texlive/texmf-dist/tex/latex/base/ts1cmr.fd)
> (/usr/share/texlive/texmf-dist/tex/latex/psnfss/ot1pnc.fd)
> *geometry* driver: auto-detecting
> *geometry* detected driver: dvips
> (/usr/share/texlive/texmf-dist/tex/latex/psnfss/ot1phv.fd) [1]
> (./d9d8962c45871ca6b62e5d3dffbe49ab.aux) )
> (see the transcript file for additional information)
> Output written on d9d8962c45871ca6b62e5d3dffbe49ab.dvi (1 page, 340 bytes).
> Transcript written on d9d8962c45871ca6b62e5d3dffbe49ab.log.
>
> And I really don't get what's happening :S
|
|
From: Pawel C. <cho...@li...> - 2013-03-31 06:50:55
|
Thank you very much - hovewer, your solution isn't enough. Adding your
lines generate:
['\\usepackage{amsmath}', '\\usepackage[T1]{fontenc}']
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/text.py", line 571, in draw
self._fontproperties, angle)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.py",
line 215, in draw_tex
Z = texmanager.get_grey(s, size, self.dpi)
File "/usr/lib/pymodules/python2.7/matplotlib/texmanager.py", line 513,
in get_grey
pngfile = self.make_png(tex, fontsize, dpi)
File "/usr/lib/pymodules/python2.7/matplotlib/texmanager.py", line 442,
in make_png
dvifile = self.make_dvi(tex, fontsize)
File "/usr/lib/pymodules/python2.7/matplotlib/texmanager.py", line 371,
in make_dvi
string:\n%s\nHere is the full report generated by LaTeX: \n\n'%
repr(tex)) + report)
RuntimeError: LaTeX was not able to process the following string:
u''
Here is the full report generated by LaTeX:
This is pdfTeX, Version 3.1415926-2.4-1.40.13 (TeX Live 2012/Debian)
restricted \write18 enabled.
entering extended mode
(./2c666a8feb5dd27d92f3c286e7775fb6.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, dumylang,
nohyphenation, po
lish, loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/type1cm/type1cm.sty)
(/usr/share/texlive/texmf-dist/tex/latex/psnfss/helvet.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty))
(/usr/share/texlive/texmf-dist/tex/latex/psnfss/courier.sty)
(/usr/share/texlive/texmf-dist/tex/latex/base/textcomp.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1enc.def))
(/usr/share/texlive/texmf-dist/tex/latex/ucs/ucs.sty
(/usr/share/texlive/texmf-dist/tex/latex/ucs/data/uni-global.def))
(/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/ucs/utf8x.def))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.def))
(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
Package geometry Warning: Over-specification in `h'-direction.
`width' (5058.9pt) is ignored.
Package geometry Warning: Over-specification in `v'-direction.
`height' (5058.9pt) is ignored.
) (./2c666a8feb5dd27d92f3c286e7775fb6.aux)
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1cmr.fd)
(/usr/share/texlive/texmf-dist/tex/latex/psnfss/t1pnc.fd)
(/usr/share/texlive/texmf-dist/tex/latex/ucs/ucsencs.def)
*geometry* driver: auto-detecting
*geometry* detected driver: dvips
(/usr/share/texlive/texmf-dist/tex/latex/psnfss/t1phv.fd)
(./2c666a8feb5dd27d92f3c286e7775fb6.aux) )
No pages of output.
Transcript written on 2c666a8feb5dd27d92f3c286e7775fb6.log.
And I still don't have slightest idea what's wrong with LaTeX in Matplotlib
:S
2013/3/31 Juergen Hasch <py...@el...>
> I tested it under Linux now, and I see your problem. The latex files don't
> compile cleanly, this is why you get the error. You can find the .tex files
> under ~./matplotlib/tex.cache
>
> It looks like you have a problem with the font encoding when using unicode
> characters.
> This works for me under Linux and Windows:
>
>
> import numpy as np
> import matplotlib as mpl
> mpl.rcParams['text.latex.**preamble'] = [r'\usepackage{amsmath}' ,
> r'\usepackage[T1]{fontenc}']
> mpl.rcParams['text.latex.**unicode'] = True
> mpl.rcParams['text.usetex'] = True
>
>
> import pylab as py
>
> py.axhspan(8400,8730,alpha=0.**15)
> py.title(u'Wyniki eksperymentu pomiaru gęstości ciała
> stałego',size='large',family='**serif')
> py.ylabel(r'$\text{lol}$',**size='large',family='serif')
> py.grid(True)
> py.show()
>
> Am 30.03.2013 22:15, schrieb Pawel Chojnacki:
>
>> 2013/3/30 Juergen Hasch <py...@el... <mailto:py...@el...>>
>>
>>
>> Am 30.03.2013 16:29, schrieb Pawel Chojnacki:
>> > 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<http://matplotlib.org/users/usetex.html>Mentions only text.usetex.
>> >
>> >
>>
>> You need to set
>> mpl.rcParams['text.usetex'] = True
>>
>> For text you need unicode, for latex raw encoding.
>> To have text and latex in one line, use
>> xlabel(u'Häallo '+r'$\varphi$'+ 'r')
>>
>> Works for me, at least.
>>
>>
>> I've already tried that, and I got the response:
>>
>> ['', '\\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/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 188, in get_text_width_height_descent
>> renderer=self)
>> File "/usr/lib/pymodules/python2.7/**matplotlib/texmanager.py", line
>> 606, in get_text_width_height_descent
>> dvifile = self.make_dvi(tex, fontsize)
>> File "/usr/lib/pymodules/python2.7/**matplotlib/texmanager.py", line
>> 351, in make_dvi
>> texfile = self.make_tex(tex, fontsize)
>> File "/usr/lib/pymodules/python2.7/**matplotlib/texmanager.py", line
>> 259, in make_tex
>> fh.write(s)
>> UnicodeEncodeError: 'ascii' codec can't encode character u'\u0119' in
>> position 349: ordinal not in range(128)
>>
>> And after adding:
>> mpl.rcParams['text.latex.**preamble'].append(r'\**usepackage{amsmath},\**
>> usepackage[utf8]{inputenc}')
>> I got:
>>
>> ['', '\\usepackage{amsmath},\\**usepackage[utf8]{inputenc}']
>> 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 1042,
>> in draw
>> ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_**to_draw,
>> renderer)
>> File "/usr/lib/pymodules/python2.7/**matplotlib/axis.py", line 993,
>> in _get_tick_bboxes
>> extent = tick.label1.get_window_extent(**renderer)
>> File "/usr/lib/pymodules/python2.7/**matplotlib/text.py", line 747,
>> in get_window_extent
>> bbox, info = self._get_layout(self._**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 188, in get_text_width_height_descent
>> renderer=self)
>> File "/usr/lib/pymodules/python2.7/**matplotlib/texmanager.py", line
>> 606, in get_text_width_height_descent
>> dvifile = self.make_dvi(tex, fontsize)
>> File "/usr/lib/pymodules/python2.7/**matplotlib/texmanager.py", line
>> 371, in make_dvi
>> string:\n%s\nHere is the full report generated by LaTeX: \n\n'%
>> repr(tex)) + report)
>> RuntimeError: LaTeX was not able to process the following string:
>> '$0.2$'
>> Here is the full report generated by LaTeX:
>>
>> This is pdfTeX, Version 3.1415926-2.4-1.40.13 (TeX Live 2012/Debian)
>> restricted \write18 enabled.
>> entering extended mode
>> (./**d9d8962c45871ca6b62e5d3dffbe49**ab.tex
>> LaTeX2e <2011/06/27>
>> Babel <v3.8m> and hyphenation patterns for english, dumylang,
>> nohyphenation, po
>> lish, loaded.
>> (/usr/share/texlive/texmf-**dist/tex/latex/base/article.**cls
>> Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
>> (/usr/share/texlive/texmf-**dist/tex/latex/base/size10.**clo))
>> (/usr/share/texlive/texmf-**dist/tex/latex/type1cm/**type1cm.sty)
>> (/usr/share/texlive/texmf-**dist/tex/latex/psnfss/helvet.**sty
>> (/usr/share/texlive/texmf-**dist/tex/latex/graphics/**keyval.sty))
>> (/usr/share/texlive/texmf-**dist/tex/latex/psnfss/courier.**sty)
>> (/usr/share/texlive/texmf-**dist/tex/latex/base/textcomp.**sty
>> (/usr/share/texlive/texmf-**dist/tex/latex/base/ts1enc.**def))
>> (/usr/share/texlive/texmf-**dist/tex/latex/amsmath/**amsmath.sty
>> For additional information on amsmath, use the `?' option.
>> (/usr/share/texlive/texmf-**dist/tex/latex/amsmath/**amstext.sty
>> (/usr/share/texlive/texmf-**dist/tex/latex/amsmath/amsgen.**sty))
>> (/usr/share/texlive/texmf-**dist/tex/latex/amsmath/amsbsy.**sty)
>> (/usr/share/texlive/texmf-**dist/tex/latex/amsmath/amsopn.**sty))
>>
>> ! LaTeX Error: Missing \begin{document}.
>>
>> See the LaTeX manual or LaTeX Companion for explanation.
>> Type H <return> for immediate help.
>> ...
>>
>> l.9 \usepackage{amsmath},
>> \usepackage[utf8]{inputenc}
>> (/usr/share/texlive/texmf-**dist/tex/latex/base/inputenc.**sty
>> (/usr/share/texlive/texmf-**dist/tex/latex/base/utf8.def
>> (/usr/share/texlive/texmf-**dist/tex/latex/base/t1enc.dfu)
>> (/usr/share/texlive/texmf-**dist/tex/latex/base/ot1enc.**dfu)
>> (/usr/share/texlive/texmf-**dist/tex/latex/base/omsenc.**dfu)
>> (/usr/share/texlive/texmf-**dist/tex/latex/base/ts1enc.**dfu)))
>> (/usr/share/texlive/texmf-**dist/tex/latex/geometry/**geometry.sty
>> (/usr/share/texlive/texmf-**dist/tex/generic/oberdiek/**ifpdf.sty)
>> (/usr/share/texlive/texmf-**dist/tex/generic/oberdiek/**ifvtex.sty)
>> (/usr/share/texlive/texmf-**dist/tex/generic/ifxetex/**ifxetex.sty)
>>
>> Package geometry Warning: Over-specification in `h'-direction.
>> `width' (5058.9pt) is ignored.
>>
>>
>> Package geometry Warning: Over-specification in `v'-direction.
>> `height' (5058.9pt) is ignored.
>>
>> )
>> No file d9d8962c45871ca6b62e5d3dffbe49**ab.aux.
>> (/usr/share/texlive/texmf-**dist/tex/latex/base/ts1cmr.fd)
>> (/usr/share/texlive/texmf-**dist/tex/latex/psnfss/ot1pnc.**fd)
>> *geometry* driver: auto-detecting
>> *geometry* detected driver: dvips
>> (/usr/share/texlive/texmf-**dist/tex/latex/psnfss/ot1phv.**fd) [1]
>> (./**d9d8962c45871ca6b62e5d3dffbe49**ab.aux) )
>> (see the transcript file for additional information)
>> Output written on d9d8962c45871ca6b62e5d3dffbe49**ab.dvi (1 page, 340
>> bytes).
>> Transcript written on d9d8962c45871ca6b62e5d3dffbe49**ab.log.
>>
>> And I really don't get what's happening :S
>>
>
>
|
|
From: Juergen H. <py...@el...> - 2013-03-31 08:04:38
|
Am 31.03.2013 08:50, schrieb Pawel Chojnacki: > Thank you very much - hovewer, your solution isn't enough. Adding your lines generate: > The problem is this: > RuntimeError: LaTeX was not able to process the following string: > u'' > Here is the full report generated by LaTeX: > Latex doesn't like the empty string. This is caused by the '\n' in your title. Can you replace your original line: py.title(u'Wyniki eksperymentu pomiaru gęstości ciała stałego\n',size='large',family='serif') with the new one, as in the example I sent you: py.title(u'Wyniki eksperymentu pomiaru gęstości ciała stałego',size='large',family='serif') |
|
From: Pawel C. <cho...@li...> - 2013-04-05 15:20:49
|
Thank you, it works flawlessly now :) 2013/3/31 Juergen Hasch <py...@el...> > Am 31.03.2013 08:50, schrieb Pawel Chojnacki: > > Thank you very much - hovewer, your solution isn't enough. Adding your >> lines generate: >> >> > The problem is this: > > > RuntimeError: LaTeX was not able to process the following string: >> u'' >> Here is the full report generated by LaTeX: >> >> > Latex doesn't like the empty string. This is caused by the '\n' in your > title. > Can you replace your original line: > py.title(u'Wyniki eksperymentu pomiaru gęstości ciała > stałego\n',size='large',**family='serif') > with the new one, as in the example I sent you: > > py.title(u'Wyniki eksperymentu pomiaru gęstości ciała > stałego',size='large',family='**serif') > > |