a bug in tex formatting?

Hello,
I am attaching my python script to this email. It makes three figures, and
everything is fine (I started with matplotlib a couple of weeks ago and so
far I love it!),
but for the way \tilde is dealt with, which seems to be a bug :
If I do r'$A\tilde{B}$' the tilde is actually on the A !! If instead I do
(like in the attached script) r'$AB\tilde$' then the tilde is on the B, but
looks pretty ugly.
Is there a quick fix? Do I need to choose another font?

thanks for your help,
Johann

gfield.py (3.3 KB)

···

------------------------------

Actually, I have other problems : I cannot save in many formats. The bmp is deemed usueless by gimp, and ps and eps save options gives the following error message (I am using matplotlib-0.90 on python/ipython 2.4) :
In [1]: show()

···

exceptions.ValueError Traceback (most recent call last)

/usr/lib/python2.4/site-packages/matplotlib/backends/backend_gtk.py in save_figu re(self, button)

630         fname = self.fileselect.get_filename_from_user()
631         if fname:

→ 632 self.canvas.print_figure(fname)
633
634 def configure_subplots(self, button):

/usr/lib/python2.4/site-packages/matplotlib/backends/backend_gtkagg.py in print_ figure(self, filename, dpi, facecolor, edgecolor, orientation, **kwargs)
112 try:
113 agg.print_figure
(filename, dpi, facecolor, edgecolor,
→ 114 orientation, **kwargs)
115 except IOError, msg:
116 error_msg_gtk(‘Failed to save\nError message: %s’%(msg,) , self)

/usr/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py in print_fig ure(self, filename, dpi, facecolor, edgecolor, orientation, **kwargs)
486 ps = self.switch_backends(FigureCanvasPS)

487                 ps.print_figure(filename, dpi, facecolor, edgecolor,

→ 488 orientation, **kwargs)
489 elif ext.find(‘pdf’)>=0:
490 from backend_pdf import FigureCanvasPdf

/usr/lib/python2.4/site-packages/matplotlib/backends/backend_ps.py in print_figu re(self, outfile, dpi, facecolor, edgecolor, orientation, papertype)
1073 self._pswriter = StringIO()
1074 renderer = RendererPS(width, height, self._pswriter, dpi=dpi )

→ 1075 self.figure.draw(renderer)
1076
1077 self.figure.set_facecolor(origfacecolor)

/usr/lib/python2.4/site-packages/matplotlib/figure.py in draw(self, renderer)
567

568         # render the axes

→ 569 for a in self.axes: a.draw(renderer)
570
571 # render the figure text

/usr/lib/python2.4/site-packages/matplotlib/axes.py in draw(self, renderer, infr ame)

1153
1154 for zorder, i, a in dsu:
→ 1155 a.draw(renderer)
1156
1157 self.transData.thaw() # release the lazy objects

/usr/lib/python2.4/site-packages/matplotlib/axis.py in draw(self, renderer, *arg s, **kwargs)

623         # the actual bbox
624         self._update_label_position(ticklabelBoxes, ticklabelBoxes2)

→ 625 self.label.draw(renderer)
626
627 self._update_offset_text_position(ticklabelBoxes, ticklabelBoxes 2)

/usr/lib/python2.4/site-packages/matplotlib/text.py in draw(self, renderer)
398
399 return
→ 400 bbox, info = self._get_layout(renderer)
401 trans = self.get_transform
()
402 if ismath==‘TeX’:

/usr/lib/python2.4/site-packages/matplotlib/text.py in _get_layout(self, rendere r)
243 heightt += 3 # 3 pixel pad
244 for line in lines:

→ 245 w,h = renderer.get_text_width_height(
246 line, self._fontproperties, ismath=self.is_math_text())
247

/usr/lib/python2.4/site-packages/matplotlib/backends/backend_ps.py in get_text_w idth_height(self, s, prop, ismath)

264
265         if ismath:

→ 266 width, height, pswriter = math_parse_s_ps(
267 s, 72, prop.get_size_in_points())
268 return width, height

/usr/lib/python2.4/site-packages/matplotlib/mathtext.py in call(self, s, dpi , fontsize, angle)
1581 expression.parseString( s )
1582
→ 1583 handler.expr.set_size_info(fontsize, dpi)

1584
1585 # set the origin once to allow w, h compution

/usr/lib/python2.4/site-packages/matplotlib/mathtext.py in set_size_info(self, f ontsize, dpi)
1197
1198 def set_size_info(self, fontsize, dpi):

→ 1199 self.elements[0].set_size_info(self._scale*fontsize, dpi)
1200 Element.set_size_info(self, fontsize, dpi)
1201 #print ‘set size’

/usr/lib/python2.4/site-packages/matplotlib/mathtext.py in set_size_info(self, f ontsize, dpi)

1108
1109 def set_size_info(self, fontsize, dpi):
→ 1110 Element.set_size_info(self, fontsize, dpi)
1111 self.metrics = Element.fonts.get_metrics(
1112 self.font
, self.sym, self.fontsize, dpi)

/usr/lib/python2.4/site-packages/matplotlib/mathtext.py in set_size_info(self, f ontsize, dpi)
1021 element.set_size_info(0.7*self.fontsize, dpi)
1022 else:

→ 1023 element.set_size_info(self.fontsize, dpi)
1024
1025 def pady(self):

/usr/lib/python2.4/site-packages/matplotlib/mathtext.py in set_size_info(self, f ontsize, dpi)
1108

1109 def set_size_info(self, fontsize, dpi):
→ 1110 Element.set_size_info(self, fontsize, dpi)
1111 self.metrics = Element.fonts.get_metrics(
1112 self.font, self.sym
, self.fontsize, dpi)

/usr/lib/python2.4/site-packages/matplotlib/mathtext.py in set_size_info(self, f ontsize, dpi)
1021 element.set_size_info(0.7*self.fontsize, dpi)
1022 else:

→ 1023 element.set_size_info(self.fontsize, dpi)
1024
1025 def pady(self):

/usr/lib/python2.4/site-packages/matplotlib/mathtext.py in set_size_info(self, f ontsize, dpi)
1108

1109 def set_size_info(self, fontsize, dpi):
→ 1110 Element.set_size_info(self, fontsize, dpi)
1111 self.metrics = Element.fonts.get_metrics(
1112 self.font, self.sym
, self.fontsize, dpi)

/usr/lib/python2.4/site-packages/matplotlib/mathtext.py in set_size_info(self, f ontsize, dpi)
1021 element.set_size_info(0.7*self.fontsize, dpi)
1022 else:

→ 1023 element.set_size_info(self.fontsize, dpi)
1024
1025 def pady(self):

/usr/lib/python2.4/site-packages/matplotlib/mathtext.py in set_size_info(self, f ontsize, dpi)
1108

1109 def set_size_info(self, fontsize, dpi):
→ 1110 Element.set_size_info(self, fontsize, dpi)
1111 self.metrics = Element.fonts.get_metrics(
1112 self.font, self.sym
, self.fontsize, dpi)

/usr/lib/python2.4/site-packages/matplotlib/mathtext.py in set_size_info(self, f ontsize, dpi)
1021 element.set_size_info(0.7*self.fontsize, dpi)
1022 else:

→ 1023 element.set_size_info(self.fontsize, dpi)
1024
1025 def pady(self):

/usr/lib/python2.4/site-packages/matplotlib/mathtext.py in set_size_info(self, f ontsize, dpi)
1108

1109 def set_size_info(self, fontsize, dpi):
→ 1110 Element.set_size_info(self, fontsize, dpi)
1111 self.metrics = Element.fonts.get_metrics(
1112 self.font, self.sym
, self.fontsize, dpi)

/usr/lib/python2.4/site-packages/matplotlib/mathtext.py in set_size_info(self, f ontsize, dpi)
1021 element.set_size_info(0.7*self.fontsize, dpi)
1022 else:

→ 1023 element.set_size_info(self.fontsize, dpi)
1024
1025 def pady(self):

/usr/lib/python2.4/site-packages/matplotlib/mathtext.py in set_size_info(self, f ontsize, dpi)
1197

1198 def set_size_info(self, fontsize, dpi):
→ 1199 self.elements[0].set_size_info(self._scale*fontsize, dpi)
1200 Element.set_size_info(self, fontsize, dpi)
1201 #print ‘set size’

/usr/lib/python2.4/site-packages/matplotlib/mathtext.py in set_size_info(self, f ontsize, dpi)
1108
1109 def set_size_info(self, fontsize, dpi):
→ 1110 Element.set_size_info(self, fontsize, dpi)

1111 self.metrics = Element.fonts.get_metrics(
1112 self.font, self.sym, self.fontsize, dpi)

/usr/lib/python2.4/site-packages/matplotlib/mathtext.py in set_size_info(self, f ontsize, dpi)

1021 element.set_size_info(0.7*self.fontsize, dpi)
1022 else:
→ 1023 element.set_size_info(self.fontsize, dpi)
1024
1025 def pady(self):

/usr/lib/python2.4/site-packages/matplotlib/mathtext.py in set_size_info(self, f ontsize, dpi)
1109 def set_size_info(self, fontsize, dpi):
1110 Element.set_size_info(self, fontsize, dpi)
→ 1111 self.metrics = Element.fonts.get_metrics(
1112 self.font, self.sym, self.fontsize, dpi)
1113

/usr/lib/python2.4/site-packages/matplotlib/mathtext.py in get_metrics(self, fon t, sym, fontsize, dpi)

799
800     def get_metrics(self, font, sym, fontsize, dpi):

→ 801 basename, metrics, sym, offset =
802 self._get_info(font, sym, fontsize, dpi)
803 return metrics

/usr/lib/python2.4/site-packages/matplotlib/mathtext.py in _get_info(self, font, sym, fontsize, dpi)
748 num = 0
749 sym = ‘.notdef’
→ 750 raise ValueError(‘unrecognized symbol “%s, %d”’ % (sym, num) )

751         filename = os.path.join(self.basepath, basename) + '.ttf'
752         if filename not in bakoma_fonts:

ValueError: unrecognized symbol “.notdef, 0”

On 3/7/07, johann cohen-tanugi <johann.cohentanugi@…287…> wrote:

Hello,

I am attaching my python script to this email. It makes three figures, and everything is fine (I started with matplotlib a couple of weeks ago and so far I love it!),

but for the way \tilde is dealt with, which seems to be a bug :

If I do r’A\tilde{B}’ the tilde is actually on the A !! If instead I do (like in the attached script) r’AB\tilde’ then the tilde is on the B, but looks pretty ugly.

Is there a quick fix? Do I need to choose another font?

thanks for your help,

Johann




---