我剛剛安裝了matplotlib,並試圖運行其中的一個示例腳本。不過,我遇到了下面詳述的錯誤。我究竟做錯了什麼?Matplotlib:「Unknown projection'3d'」error
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.gca(projection='3d')
X, Y, Z = axes3d.get_test_data(0.05)
cset = ax.contour(X, Y, Z, 16, extend3d=True)
ax.clabel(cset, fontsize=9, inline=1)
plt.show()
的錯誤是
Traceback (most recent call last):
File "<string>", line 245, in run_nodebug
File "<module1>", line 5, in <module>
File "C:\Python26\lib\site-packages\matplotlib\figure.py", line 945, in gca
return self.add_subplot(111, **kwargs)
File "C:\Python26\lib\site-packages\matplotlib\figure.py", line 677, in add_subplot
projection_class = get_projection_class(projection)
File "C:\Python26\lib\site-packages\matplotlib\projections\__init__.py", line 61, in get_projection_class
raise ValueError("Unknown projection '%s'" % projection)
ValueError: Unknown projection '3d'
看看這個主題:http://comments.gmane.org/gmane.comp.python.matplotlib.devel/8904 – 2010-09-28 08:20:57
它適用於我。 Windows XP,Active狀態python 2.6.5 matplotlib 1.0.0。 – joaquin 2010-09-28 09:15:01
你使用的是什麼版本的Python? – 2017-09-05 21:04:17