Python 属性错误:';numpy.ndarray和#x27;对象没有属性';获取矩阵&x27;
我正在尝试使用mlpy绘制一个精彩的PCA,而Python 属性错误:';numpy.ndarray和#x27;对象没有属性';获取矩阵&x27;,python,matplotlib,Python,Matplotlib,我正在尝试使用mlpy绘制一个精彩的PCA,而plt.scatter的c参数导致了一个异常 数据集: 我有以下错误: Traceback (most recent call last): File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper draw(artist, renderer, *args, **kwargs) File "/Library/Pytho
plt.scatter
的c
参数导致了一个异常
数据集:
我有以下错误:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Library/Python/2.7/site-packages/matplotlib/figure.py", line 1050, in draw
func(*args)
File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Library/Python/2.7/site-packages/matplotlib/axes/_base.py", line 2075, in draw
a.draw(renderer)
File "/Library/Python/2.7/site-packages/matplotlib/collections.py", line 729, in draw
Collection.draw(self, renderer)
File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Library/Python/2.7/site-packages/matplotlib/collections.py", line 301, in draw
self._offset_position)
File "/Library/Python/2.7/site-packages/matplotlib/backends/backend_macosx.py", line 79, in draw_path_collection
all_transforms = [t.get_matrix() for t in all_transforms]
AttributeError: 'numpy.ndarray' object has no attribute 'get_matrix'
当我在
plt.scatter
中删除c=y
时,它会运行,但我有一种颜色,不允许我识别组。这与这里的代码完全相同:可能需要先清理一下源代码。例如,定义data=np.zero(shape=(4,4))
,然后立即将其重新定义为data=np.array(iris)
;很难确定目的是什么。@user3091978您能做一个简单的可复制的示例吗?
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Library/Python/2.7/site-packages/matplotlib/figure.py", line 1050, in draw
func(*args)
File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Library/Python/2.7/site-packages/matplotlib/axes/_base.py", line 2075, in draw
a.draw(renderer)
File "/Library/Python/2.7/site-packages/matplotlib/collections.py", line 729, in draw
Collection.draw(self, renderer)
File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Library/Python/2.7/site-packages/matplotlib/collections.py", line 301, in draw
self._offset_position)
File "/Library/Python/2.7/site-packages/matplotlib/backends/backend_macosx.py", line 79, in draw_path_collection
all_transforms = [t.get_matrix() for t in all_transforms]
AttributeError: 'numpy.ndarray' object has no attribute 'get_matrix'