为什么我的matplotlib有这个错误

时间:2014-01-06 14:05:23

标签: python matplotlib

我正在尝试使用:

在matplotlib中制作一些数据的散点图
ax.scatter(X, Y, Z, c='r', marker='0')

但是,我收到以下错误:

 Traceback (most recent call last):
    File "C:\Users\K\Desktop\3d", line 11, in <module>
    ax.scatter(X, Y, Z, c='r', marker='0')
    File "C:\Python27\ArcGIS10.1\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py", line 2180, in scatter
    patches = Axes.scatter(self, xs, ys, s=s, c=c, *args, **kwargs)
    File "C:\Python27\ArcGIS10.1\lib\site-packages\matplotlib\axes.py", line 6296, in scatter
    marker_obj = mmarkers.MarkerStyle(marker)
    File "C:\Python27\ArcGIS10.1\lib\site-packages\matplotlib\markers.py", line 162, in __init__
    self.set_marker(marker)
    File "C:\Python27\ArcGIS10.1\lib\site-packages\matplotlib\markers.py", line 233, in set_marker
    Path(marker)
    File "C:\Python27\ArcGIS10.1\lib\site-packages\matplotlib\path.py", line 147, in __init__
    assert vertices.ndim == 2
    AssertionError

我错过了什么?我看不出有什么不妥。

1 个答案:

答案 0 :(得分:3)

您的问题似乎是由于0误认为o

尝试ax.scatter(X, Y, Z, c='r', marker='o')(而不是marker='0')。

如果您传入的制造商不是matplotlib的标记代码之一,则会假定您传入的顶点数组可以转换为可用作标记的路径。因此,你收到的有点神秘的错误。

如果您想要文字0作为标记,请使用marker='$0$'。美元符号表示乳胶格式的字符串,matplotlib将用作标记。