Python:matplotlib'numpy.ndarray'对象没有属性'has_data'

Eat*_*how 4 python numpy data-visualization matplotlib

我想用matplotlib模块获得3D图.以下是我的一些源代码.

(LTV,DTI,FICO) = readData('Acquisition_2007Q1.txt')
x = np.array(LTV)
y = np.array(DTI)
z = np.array(FICO)

fig = plt.figure()
ax = fig.gca(projection='3d')
Axes3D.plot_trisurf(x, y, z, cmap = cm.jet)
Run Code Online (Sandbox Code Playgroud)

x,y以及z是这样的:

array([56, 56, 56, ..., 62, 62, 62])
array([37, 37, 37, ..., 42, 42, 42])
array([734, 734, 734, ..., 709, 709, 709])
Run Code Online (Sandbox Code Playgroud)

但是,我收到以下错误:

AttributeError                            Traceback (most recent call last)
<ipython-input-22-5c9578cf3311> in <module>()
      1 fig = plt.figure()
      2 ax = fig.gca(projection='3d')
----> 3 Axes3D.plot_trisurf(x, y, z, cmap = cm.jet)

/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/mpl_toolkits/mplot3d/axes3d.py in plot_trisurf(self, *args, **kwargs)
   1828         """
   1829 
-> 1830         had_data = self.has_data()
   1831 
   1832         # TODO: Support custom face colours

AttributeError: 'numpy.ndarray' object has no attribute 'has_data'
Run Code Online (Sandbox Code Playgroud)

tac*_*ell 11

它应该是

(LTV,DTI,FICO) = readData('Acquisition_2007Q1.txt')
x = np.array(LTV)
y = np.array(DTI)
z = np.array(FICO)

fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot_trisurf(x, y, z, cmap = cm.jet)
Run Code Online (Sandbox Code Playgroud)

Axes3D.plot_trisurf线被调用的未结合的类方法plot_trisurf的的Axes3D类.它期望一个实例Axes3D成为第一个参数(通常在方法绑定到实例时处理).