在Jupyter中导入Axes3D时出现关键错误

2024-03-29 01:09:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试导入Axes3D,代码如下:

from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = fig.add_subplot(111, projection = '3d')
ax.scatter(X_train['width'], X_train['height'], X_train['color_score'], c = y_train, marker = 'o', s=100)
ax.set_xlabel('width')
ax.set_ylabel('height')
ax.set_zlabel('color_score')
plt.show()

我尝试执行此操作时出错:KeyError:“缩放类型”

导入工作正常如果我只是导入mpl_工具包,我也通过提示符在anaconda中安装了正确的库

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-79-f5d43cd798d1> in <module>
----> 1 from mpl_toolkits.mplot3d import Axes3D
      2 
      3 fig = plt.figure()
      4 ax = fig.add_subplot(111, projection = '3D')
      5 ax.scatter(X_train['width'], X_train['height'], X_train['color_score'], c = y_train, marker = 'o', s=100)

~\Anaconda3\lib\site-packages\mpl_toolkits\mplot3d\__init__.py in <module>
----> 1 from .axes3d import Axes3D

~\Anaconda3\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py in <module>
     40 
     41 
---> 42 class Axes3D(Axes):
     43     """
     44     3D axes object.

~\Anaconda3\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py in Axes3D()
     50     def __init__(
     51             self, fig, rect=None, *args,
---> 52             azim=-60, elev=30, zscale=None, sharez=None, proj_type='persp',
     53             **kwargs):
     54         """

~\Anaconda3\lib\site-packages\matplotlib\docstring.py in dedent_interpd(func)
    114     """Dedent *func*'s docstring, then interpolate it with ``interpd``."""
    115     func.__doc__ = inspect.getdoc(func)
--> 116     return interpd(func)
    117 
    118 

~\Anaconda3\lib\site-packages\matplotlib\docstring.py in __call__(self, func)
     38     def __call__(self, func):
     39         if func.__doc__:
---> 40             func.__doc__ %= self.params
     41         return func
     42 

KeyError: 'scale_type'

进口有什么问题


Tags: inpyselflibpackagesfigsitetrain