我有两个数组,我取它们的日志。当我这样做并试图绘制散点图时,我得到了一个错误:
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.
代码很简单:
^{pr2}$知道是什么原因造成的吗?谢谢。在
这对我来说很成功
所以也许问题出在你没有给我们看的东西上。你能提供一个完整的示例代码片段吗?这样我们就可以重现你的问题了吗?在
我最近也遇到了同样的问题:
我的问题是我的X和Y(numpy)数组是由128位浮点组成的。在
在这种情况下,解决方案是将数组重新转换为较低精度的浮点,即
array = numpy.float64(array)
希望这有帮助:~)
新答案:
从源代码看,如果传入仿射_变换的点数组维数错误或为空,则会引发此错误。以下是相关线路:
在继续之前,先看看myarray_x和myarray_y数组的维数。在
旧答案:
我最好的猜测是,您正在获取值的日志<;=0。这将在数组中为您提供nan或-inf(在等于0的情况下),这当然无法绘制。在
(不过,惠索是对的-这些观点被忽略了)
相关问题 更多 >
编程相关推荐