python错误:AttributeError: module ’matplotlib‘ has no attribute ’plot‘(已解决)

import numpy as np
import matplotlib as plt

x = np.array([1,2,3,4,5,6,7,8])
y = np.random.randint(5,size = 8)
plt.plot(x,y,'r')
plt.show()

出现错误

    plt.plot(x,y,'r')
AttributeError: module 'matplotlib' has no attribute 'plot'

应该把

import matplotlib as plt

改成

import matplotlib.pyplot as plt

import numpy as np
import matplotlib.pyplot as plt

x = np.array([1,2,3,4,5,6,7,8])
y = np.random.randint(5,size = 8)
plt.plot(x,y,'r')
plt.show()

python错误:AttributeError: module ’matplotlib‘ has no attribute ’plot‘(已解决)_第1张图片

你可能感兴趣的:(Python问题处理,python,numpy,matplotlib)