Hi,
I have installed matplotlib-0.80 on WinXP and when I run a Python script that calls pylab.plot
several times after a while the program ends with the error message listed below. I inserted some print statements into backend_agg.py and text.py (code snippets see below). As far as I can see the problem is with the function xy_tup that returns (70.0555555556, -3509680569.77) when given the input (-0.030476944389471572, -0.012864052691159839).
My workaround is to set:
try:
self._renderer.draw_text(font, int(x), int(y), gc)
except:
pass
in backend_agg.py
Is there anything I can do instead to avoid this error message?
With kind regards
Rolf Wester
···
-------------------------------------------------------------------------------------------------
text.py
def draw(self, renderer):
...
bbox, info = self._get_layout(renderer)
-> print "draw ", info,
for line, wh, x, y in info:
x, y = self._transform.xy_tup((x, y))
-> print x,y," / ",
#renderer.draw_arc(gc, (1,0,0),
# x, y, 2, 2, 0.0, 360.0)
if renderer.flipy():
canvasw, canvash = renderer.get_canvas_width_height()
y = canvash-y
-> print y, canvash
renderer.draw_text(gc, x, y, line,
self._fontproperties, angle,
ismath=self.is_math_text())
------------------------------------------------
backend_agg.py:
def draw_text(self, gc, x, y, s, prop, angle, ismath):
"""
Render the text
"""
if __debug__: verbose.report('RendererAgg.draw_text', 'debug-annoying')
if ismath:
return self.draw_mathtext(gc, x, y, s, prop, angle)
font = self._get_agg_font(prop)
if font is None: return None
if len(s)==1 and ord(s)>127:
font.load_char(ord(s))
else:
font.set_text(s, angle)
font.draw_glyphs_to_bitmap()
-> print font, int(x), int(y), gc
self._renderer.draw_text(font, int(x), int(y), gc)
--------------------------------------------------------------
Shell
...
draw [('0', (7.0, 10.0), -0.030476944389471572, -0.012864052691159839)] 70.0555555556 -3509680569.77 / 3509681061.77 492.0
<FT2Font object at 0x0132DEAC> 70 3509681061 <matplotlib.backend_bases.GraphicsContextBase instance at 0x1B340F80>
Traceback (most recent call last):
File "E:\work\trumpf\kaustikopti6659mmAK2ma.py", line 238, in -toplevel-
intensity_nf, intensity_ff = opt_resonator_online(GRIDLIST, OELIST, outcoupler, SEQUENCELIST1, SEQUENCELIST2, no_fc, init_kind, nit, nav, verbose=verbose, plot = plot, genplot = gen_plot)
File "D:\PROGLA~1\Python23\lib\site-packages\OPT\opt_resonator.py", line 473, in opt_resonator_online
if plot: genplot.plot_slice(fc_outcouple, ifigure = 2, clear = 'yes', nr = 1, nc = 2, nf = 1, slice = 1, xlabel = '$r$', i=0, ylabel = '$Intensity$', title = '$nearfield$')
File "D:\PROGLA~1\Python23\lib\site-packages\OPT\opt_graphics.py", line 507, in plot_slice
xlabel = xlabel, ylabel = ylabel, title = title)
File "D:\PROGLA~1\Python23\lib\site-packages\OPT\opt_graphics.py", line 560, in plot_slice_matplotlib
pylab.plot(x,xslice)
File "D:\PROGLA~1\Python23\Lib\site-packages\matplotlib\pylab.py", line 1900, in plot
draw_if_interactive()
File "D:\PROGLA~1\Python23\Lib\site-packages\matplotlib\backends\backend_tkagg.py", line 58, in draw_if_interactive
figManager.show()
File "D:\PROGLA~1\Python23\Lib\site-packages\matplotlib\backends\backend_tkagg.py", line 292, in show
self.canvas.draw()
File "D:\PROGLA~1\Python23\Lib\site-packages\matplotlib\backends\backend_tkagg.py", line 146, in draw
FigureCanvasAgg.draw(self)
File "D:\PROGLA~1\Python23\lib\site-packages\matplotlib\backends\backend_agg.py", line 312, in draw
self.figure.draw(renderer)
File "D:\PROGLA~1\Python23\Lib\site-packages\matplotlib\figure.py", line 395, in draw
for a in self.axes: a.draw(renderer)
File "D:\PROGLA~1\Python23\Lib\site-packages\matplotlib\axes.py", line 1362, in draw
self.yaxis.draw(renderer)
File "D:\PROGLA~1\Python23\Lib\site-packages\matplotlib\axis.py", line 524, in draw
tick.draw(renderer)
File "D:\PROGLA~1\Python23\Lib\site-packages\matplotlib\axis.py", line 141, in draw
if self.label1On: self.label1.draw(renderer)
File "D:\PROGLA~1\Python23\lib\site-packages\matplotlib\text.py", line 332, in draw
ismath=self.is_math_text())
File "D:\PROGLA~1\Python23\lib\site-packages\matplotlib\backends\backend_agg.py", line 211, in draw_text
self._renderer.draw_text(font, int(x), int(y), gc)
TypeError: CXX: type error.
>>>
--
-------------------------------------
Rolf Wester
rolf.wester@...224...