Pycharm中matplotlib出错

Pycharm中matplotlib出错

用python里面的matplotlib画3D图,运行代码如下

import numpy
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

theta = numpy.linspace(0, 3.14*4, 200)
r = numpy.linspace(0, 1, 200)
x = r * numpy.cos(theta)
y = r * numpy.sin(theta)
z = numpy.linspace(0, 2, 200)

fig = plt.figure(figsize=(12, 7))
ax1 = plt.axes(projection='3d')
ax1.plot(x, y, z)
plt.show()

但是matplotlib一直出错,错误如下

Traceback (most recent call last):
  File "C:/Users/user/PycharmProjects/Introduction to Python3/Introduction to Python Smallpiece 2018/Variables/3Dpictures.py", line 2, in <module>
    import matplotlib.pyplot as plt
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\matplotlib\pyplot.py", line 2372, in <module>
    switch_backend(rcParams["backend"])
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\matplotlib\pyplot.py", line 207, in switch_backend
    backend_mod = importlib.import_module(backend_name)
  File "D:\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\matplotlib\backends\backend_tkagg.py", line 1, in <module>
    from . import _backend_tk
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\matplotlib\backends\_backend_tk.py", line 11, in <module>
    from . import _tkagg
ImportError: cannot import name '_tkagg' from 'matplotlib.backends' (C:\Users\user\AppData\Roaming\Python\Python37\site-packages\matplotlib\backends\__init__.py)

Process finished with exit code 1

求各位大佬帮忙解决一下

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值