Trouble with mathtext.py

Hi all,

I have some trouble with the following lines

title(r'\\underline\{\\lambda\}\_n= '+str(f))
plot(arange(0,len(data)),data,lw=2)
xlabel('Iterations')
ylabel('Largest eigenvalue')
savefig('yuanlbl.png')

IIRC the code worked before the recent changes in
svn. How can I resolve the problem ?

Traceback (most recent call last):
   File "yuan2.py", line 84, in <module>
     savefig('yuanlbl.png')
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/pyplot.py", line 269, in savefig
     return fig.savefig(*args, **kwargs)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/figure.py", line 782, in savefig
     self.canvas.print_figure(*args, **kwargs)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/backend_bases.py", line 1195, in print_figure
     **kwargs)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/backends/backend_gtkagg.py", line 103, in print_png
     return agg.print_png(filename, *args, **kwargs)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/backends/backend_agg.py", line 396, in print_png
     self.draw()
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/backends/backend_agg.py", line 358, in draw
     self.figure.draw(self.renderer)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/figure.py", line 624, in draw
     for a in self.axes: a.draw(renderer)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/axes.py", line 1345, in draw
     a.draw(renderer)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/text.py", line 317, in draw
     bbox, info = self._get_layout(renderer)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/text.py", line 201, in _get_layout
     line, self._fontproperties, ismath=self.is_math_text(line))
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/backends/backend_agg.py", line 233, in get_text_width_height_descent
     self.mathtext_parser.parse(s, self.dpi.get(), prop)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/mathtext.py", line 2729, in parse
     box = self._parser.parse(s, font_output, fontsize, dpi)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/mathtext.py", line 2204, in parse
     str(err)]))
ValueError:
\\underline\{\\lambda\}\_n= 443.75221866615522
^
Expected end of text (at char 0), (line:1, col:1)

Nils

The built-in mathtext support does not support "\underline" (and never did AFAICT).

It sounds like you had "text.usetex" turned on in your matplotlibrc, and now for some reason or other you don't.

Cheers,
Mike

Nils Wagner wrote:

···

Hi all,

I have some trouble with the following lines

title(r'\\underline\{\\lambda\}\_n= '+str(f))
plot(arange(0,len(data)),data,lw=2)
xlabel('Iterations')
ylabel('Largest eigenvalue')
savefig('yuanlbl.png')

IIRC the code worked before the recent changes in
svn. How can I resolve the problem ?

Traceback (most recent call last):
   File "yuan2.py", line 84, in <module>
     savefig('yuanlbl.png')
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/pyplot.py", line 269, in savefig
     return fig.savefig(*args, **kwargs)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/figure.py", line 782, in savefig
     self.canvas.print_figure(*args, **kwargs)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/backend_bases.py", line 1195, in print_figure
     **kwargs)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/backends/backend_gtkagg.py", line 103, in print_png
     return agg.print_png(filename, *args, **kwargs)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/backends/backend_agg.py", line 396, in print_png
     self.draw()
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/backends/backend_agg.py", line 358, in draw
     self.figure.draw(self.renderer)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/figure.py", line 624, in draw
     for a in self.axes: a.draw(renderer)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/axes.py", line 1345, in draw
     a.draw(renderer)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/text.py", line 317, in draw
     bbox, info = self._get_layout(renderer)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/text.py", line 201, in _get_layout
     line, self._fontproperties, ismath=self.is_math_text(line))
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/backends/backend_agg.py", line 233, in get_text_width_height_descent
     self.mathtext_parser.parse(s, self.dpi.get(), prop)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/mathtext.py", line 2729, in parse
     box = self._parser.parse(s, font_output, fontsize, dpi)
   File "/usr/local/lib64/python2.5/site-packages/matplotlib/mathtext.py", line 2204, in parse
     str(err)]))
ValueError:
\\underline\{\\lambda\}\_n= 443.75221866615522
^
Expected end of text (at char 0), (line:1, col:1)

Nils

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA