当我尝试在pycharm中绘制3D对象时,我收到此错误:
TypeError: 'module' object is not callable
代码结构:
# visualizing data with pyplot
#usings
import numpy as np
import matplotlib.pyplot as plt
import urllib
from mpl_toolkits.mplot3d import axes3d
#main code
fig=plt.figure()
ax=axes3d(fig)
t=np.linspace(0,5*np.pi,501)
ax.plot(np.cos(t),np.sin(t),t)
plt.show()
答案 0 :(得分:0)
参见工作代码示例here。
我为ax=axes3d(fig)
交换了ax=axes3d(fig)
行,但运行正常。
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d
#main code
fig=plt.figure()
ax = fig.gca(projection='3d')
t=np.linspace(0,5*np.pi,501)
ax.plot(np.cos(t),np.sin(t),t)
plt.show()