Python ERROR:ValueError: Unknown projection '3d'

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Felaim/article/details/84860983

这个主要是matplotlib版本的问题

新版本绘制三维散点的方式:

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

Prior to version 1.0.0, the method of creating a 3D axes was different. For those using older versions of matplotlib, change ax = fig.add_subplot(111, projection=‘3d’) to ax = Axes3D(fig).如果是比较老版本的matplotlib小伙伴们要使用如下的方式

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = Axes3D(fig)

O(∩_∩)O哈哈~

参考地址:https://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html

猜你喜欢

转载自blog.csdn.net/Felaim/article/details/84860983