Hello, I am using scatter to plot simple arrays. It seems to crash when I scatter an array of length 3. any other length works fine. I’m not savvy enough to know how to track this bug down. here is my code, and below that I pasted the error message the IDLE gave me. what might be the problem? thanks.
My code:
from pylab import *
array = [2,3,4]
faceColor = (1,1,1)
scatter(range(len(array)),
array,
marker=‘o’,
c=faceColor,
edgecolor='k',
linewidth=1,
alpha=0.5,
s=50,
label='hi')
show()
the error message:
Traceback (most recent call last):
File “C:/Documents and Settings/TEMP/Desktop/test.py”, line 15, in -toplevel-
label=‘hi’)
File
“C:\Python24\Lib\site-packages\matplotlib\pylab.py”, line 2192, in scatter
ret = gca().scatter(*args, **kwargs)
File “C:\Python24\lib\site-packages\matplotlib\axes.py”, line 3082, in scatter
collection.set_array(c)
File “C:\Python24\Lib\site-packages\matplotlib\cm.py”, line 60, in set_array
self._A = A.astype(nx.Float32)
AttributeError: ‘tuple’ object has no attribute ‘astype’
···
Yahoo! Mail
Bring photos to life! New PhotoMail makes sharing a breeze.
Try giving a numpy array for the facecolor argument :
..., c = numpy.array(faceColor), ...
The scatter function seems to need a numpy array, not just any python sequence.
David
2006/3/8, Jeff Peery <jeffpeery@...9...>:
···
Hello, I am using scatter to plot simple arrays. It seems to crash when I
scatter an array of length 3. any other length works fine. I'm not savvy
enough to know how to track this bug down. here is my code, and below that I
pasted the error message the IDLE gave me. what might be the problem?
thanks.
My code:
from pylab import *
array = [2,3,4]
faceColor = (1,1,1)
scatter(range(len(array)),
array,
marker='o',
c=faceColor,
edgecolor='k',
linewidth=1,
alpha=0.5,
s=50,
label='hi')
show()
the error message:
Traceback (most recent call last):
File "C:/Documents and Settings/TEMP/Desktop/test.py", line 15, in
-toplevel-
label='hi')
File
"C:\Python24\Lib\site-packages\matplotlib\pylab.py", line
2192, in scatter
ret = gca().scatter(*args, **kwargs)
File "C:\Python24\lib\site-packages\matplotlib\axes.py",
line 3082, in scatter
collection.set_array(c)
File "C:\Python24\Lib\site-packages\matplotlib\cm.py",
line 60, in set_array
self._A = A.astype(nx.Float32)
AttributeError: 'tuple' object has no attribute 'astype'
>>>
________________________________
Yahoo! Mail
Bring photos to life! New PhotoMail makes sharing a breeze.