Matplotlib:绘制正弦函数时此代码错误

时间:2019-03-13 08:26:01

标签: python numpy matplotlib

import pandas as pd
import matplotlib as plt
import numpy as np

x = np.linspace(0,10,10)
y = np.sin(x)

plt.plot(x,y)

(最近通话最近):

File "<ipython-input-18-d8b592bf313e>", line 1, in <module>
    plt.plot(x,y)

AttributeError: module 'matplotlib' has no attribute 'plot'

2 个答案:

答案 0 :(得分:0)

您需要导入matplotlib.pyplot而不是matplotlib

import matplotlib.pyplot as plt

答案 1 :(得分:0)

您需要从matplotlib包中导入pyplot模块: import matplotlib.pyplot as plt