bug in grid plotting, apparent in postscript driver

Dear all,

The following simple script gives an error on matplotlib-0.72.1:
# Start script
from pylab import *
from Numeric import *

x=arange(0.1,10,0.1)
y=sin(x)

grid()
plot(x,y)
savefig('foo.eps')
# end script

The error disappears when I remove the grid() switch.

The error message is:
   File "foo.py", line 10, in ?
     savefig('foo.eps')
   File "/usr/lib/python2.3/site-packages/matplotlib/pylab.py", line 763,
in savefig
     try: ret = fig.savefig(*args, **kwargs)
   File "/usr/lib/python2.3/site-packages/matplotlib/figure.py", line
455, in savefig
     self.canvas.print_figure(*args, **kwargs)
   File
"/usr/lib/python2.3/site-packages/matplotlib/backends/backend_ps.py",
line 646, in print_figure
     self.figure.draw(renderer)
   File "/usr/lib/python2.3/site-packages/matplotlib/figure.py", line
338, in draw
     for a in self.axes: a.draw(renderer)
   File "/usr/lib/python2.3/site-packages/matplotlib/axes.py", line 1281,
in draw
     self.xaxis.draw(renderer)
   File "/usr/lib/python2.3/site-packages/matplotlib/axis.py", line 523,
in draw
     tick.draw(renderer)
   File "/usr/lib/python2.3/site-packages/matplotlib/axis.py", line 135,
in draw
     if midPoint and self.gridOn: self.gridline.draw(renderer)
   File "/usr/lib/python2.3/site-packages/matplotlib/lines.py", line 283,
in draw
     lineFunc(renderer, gc, xt, yt)
   File "/usr/lib/python2.3/site-packages/matplotlib/lines.py", line 569,
in _draw_dotted
     renderer.draw_lines(gc, xt, yt)
   File
"/usr/lib/python2.3/site-packages/matplotlib/backends/backend_ps.py",
line 355, in draw_lines
     self._draw_lines(gc,to_draw)
   File
"/usr/lib/python2.3/site-packages/matplotlib/backends/backend_ps.py",
line 338, in _draw_lines
     self._draw_ps("\n".join(ps), gc, None)
   File
"/usr/lib/python2.3/site-packages/matplotlib/backends/backend_ps.py",
line 453, in _draw_ps
     self.set_linewidth(gc.get_linewidth())
   File
"/usr/lib/python2.3/site-packages/matplotlib/backends/backend_ps.py",
line 114, in set_linewidth
     self._pswriter.write("%1.3f setlinewidth\n"%linewidth)
TypeError: float argument required

The error disappears (or at least is no longer visible) when I replace line 113 in backend_ps.py by:

self._pswriter.write("%1.3f setlinewidth\n"%float(linewidth))

I hope someone can make a thorough fix. At the moment I can live with my workaround.

Cheers, Arnold

···

--
------------------------------------------------------------------------
Arnold F. Moene NEW tel: +31 (0)317 482604
Meteorology and Air Quality Group fax: +31 (0)317 482811
Wageningen University e-mail: Arnold.Moene at wur.nl
Duivendaal 2 url: http://www.met.wau.nl
6701 AP Wageningen
The Netherlands
------------------------------------------------------------------------
Openoffice.org - Freedom at work
Firefox - The browser you can trust (www.mozilla.org)
------------------------------------------------------------------------

I don't know if it could help, but with matplotlib 0.71, the version I've installed, the error doesn't occur.

HTH,
  Andrea.

···

On 3 Mar 2005, at 16:14, Arnold Moene wrote:

Dear all,

The following simple script gives an error on matplotlib-0.72.1:
# Start script
from pylab import *
from Numeric import *

x=arange(0.1,10,0.1)
y=sin(x)

grid()
plot(x,y)
savefig('foo.eps')
# end script