Matplotlib: “Unknown projection '3d'” error

前端 未结 5 2014
南笙
南笙 2020-12-07 16:00

I just installed matplotlib and am trying to run one of there example scripts. However I run into the error detailed below. What am I doing wrong?

from mpl_         


        
5条回答
  •  一整个雨季
    2020-12-07 16:52

    I encounter the same problem, and @Joe Kington and @bvanlew's answer solve my problem.

    but I should add more infomation when you use pycharm and enable auto import.

    when you format the code, the code from mpl_toolkits.mplot3d import Axes3D will auto remove by pycharm.

    so, my solution is

    from mpl_toolkits.mplot3d import Axes3D
    Axes3D = Axes3D  # pycharm auto import
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    

    and it works well!

提交回复
热议问题