【发布时间】:2011-02-11 05:05:43
【问题描述】:
我有两个数组,我记录了它们的日志。当我这样做并尝试绘制他们的散点图时,我得到了这个错误:
File "/Library/Python/2.6/site-packages/matplotlib-1.0.svn_r7892-py2.6-macosx-10.6-universal.egg/matplotlib/pyplot.py", line 2192, in scatter
ret = ax.scatter(x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, faceted, verts, **kwargs)
File "/Library/Python/2.6/site-packages/matplotlib-1.0.svn_r7892-py2.6-macosx-10.6-universal.egg/matplotlib/axes.py", line 5384, in scatter
self.add_collection(collection)
File "/Library/Python/2.6/site-packages/matplotlib-1.0.svn_r7892-py2.6-macosx-10.6-universal.egg/matplotlib/axes.py", line 1391, in add_collection
self.update_datalim(collection.get_datalim(self.transData))
File "/Library/Python/2.6/site-packages/matplotlib-1.0.svn_r7892-py2.6-macosx-10.6-universal.egg/matplotlib/collections.py", line 153, in get_datalim
offsets = transOffset.transform_non_affine(offsets)
File "/Library/Python/2.6/site-packages/matplotlib-1.0.svn_r7892-py2.6-macosx-10.6-universal.egg/matplotlib/transforms.py", line 1924, in transform_non_affine
self._a.transform(points))
File "/Library/Python/2.6/site-packages/matplotlib-1.0.svn_r7892-py2.6-macosx-10.6-universal.egg/matplotlib/transforms.py", line 1420, in transform
return affine_transform(points, mtx)
ValueError: Invalid vertices array.
代码很简单:
myarray_x = log(my_array[:, 0])
myarray_y = log(my_array[:, 1])
plt.scatter(myarray_x, myarray_y)
知道是什么原因造成的吗?谢谢。
【问题讨论】:
-
您需要指定更多信息。例如在调用
plt.scatter之前查看myarray_x、myarray_y
标签: python numpy matplotlib scipy