show and savefig : cannot convert float NaN to integer

Hi everyone,

I am very new to Python and Matplotlib, so it might be easier than I think. I am doing something like this:

y = np.zeros((len(array1),len(array2)), dtype=float)

for i in range(len(y)):

y[i][i]= array2[i]

for i in range(len(y)):

plt.plot(array1, y[i])

#plt.savefig(filename)

plt.show()

where array1 and array2 are one dimensional, all elements with data type float. y [i] has all elements zero except one.

My configuration is:

Executing on (‘Linux’, ‘Lap’, ‘2.6.31-19-generic-pae’, ‘#56-Ubuntu SMP Thu Jan 28 02:29:51 UTC 2010’, ‘i686’)

Python version 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)

[GCC 4.4.1]

matplotlib version 0.99.0

and I am getting following error:

Traceback (most recent call last):

File “/usr/lib/python2.6/lib-tk/Tkinter.py”, line 1413, in call

return self.func(*args)

File “/usr/lib/pymodules/python2.6/matplotlib/backends/backend_tkagg.py”, line 212, in resize

self.show()

File “/usr/lib/pymodules/python2.6/matplotlib/backends/backend_tkagg.py”, line 215, in draw

FigureCanvasAgg.draw(self)

File “/usr/lib/pymodules/python2.6/matplotlib/backends/backend_agg.py”, line 314, in draw

self.figure.draw(self.renderer)

File “/usr/lib/pymodules/python2.6/matplotlib/artist.py”, line 46, in draw_wrapper

draw(artist, renderer, *kl)

File “/usr/lib/pymodules/python2.6/matplotlib/figure.py”, line 774, in draw

for a in self.axes: a.draw(renderer)

File “/usr/lib/pymodules/python2.6/matplotlib/artist.py”, line 46, in draw_wrapper

draw(artist, renderer, *kl)

File “/usr/lib/pymodules/python2.6/matplotlib/axes.py”, line 1721, in draw

a.draw(renderer)

File “/usr/lib/pymodules/python2.6/matplotlib/artist.py”, line 46, in draw_wrapper

draw(artist, renderer, *kl)

File “/usr/lib/pymodules/python2.6/matplotlib/axis.py”, line 742, in draw

tick.draw(renderer)

File “/usr/lib/pymodules/python2.6/matplotlib/artist.py”, line 46, in draw_wrapper

draw(artist, renderer, *kl)

File “/usr/lib/pymodules/python2.6/matplotlib/axis.py”, line 196, in draw

self.label1.draw(renderer)

File “/usr/lib/pymodules/python2.6/matplotlib/text.py”, line 565, in draw

ismath=ismath)

File “/usr/lib/pymodules/python2.6/matplotlib/backends/backend_agg.py”, line 134, in draw_text

self._renderer.draw_text_image(font.get_image(), int(x), int(y) + 1, angle, gc)

ValueError: cannot convert float NaN to integer

I am not sure what is going wrong, I checked the data types several times but no clue.

Many thanks

Abhishek