plot is not defined

前端 未结 2 1914
醉酒成梦
醉酒成梦 2021-02-07 07:46

I started to use matplotlib library to get a graph. But when I use \"plot(x,y)\" it returns me that \"plot is not defined\".

To import , I used the following command:

2条回答
  •  礼貌的吻别
    2021-02-07 08:32

    Change that import to

    from matplotlib.pyplot import *
    

    Note that this style of imports (from X import *) is generally discouraged. I would recommend using the following instead:

    import matplotlib.pyplot as plt
    plt.plot([1,2,3,4])
    

提交回复
热议问题