【Python-BUG】module ‘matplotlib‘ has no attribute ‘plot‘
作者:互联网
问题所在
import matplotlib.pyplot as plt
#很容易漏掉pyplot ,直接写成 import matplotlib as plt导致错误
错误写法
import numpy as np
import matplotlib as plt
# 随机漫步
position=0
walk=[position]
steps=1000
for i in range(steps):
step= 1 if np.random.randint(0,2) else -1
position+=step
walk.append(position)
plt.plot(walk)
正确写法
import numpy as np
import matplotlib.pyplot as plt
# 随机漫步
position=0
walk=[position]
steps=1000
for i in range(steps):
step= 1 if np.random.randint(0,2) else -1
position+=step
walk.append(position)
plt.plot(walk)
标签:plot,plt,no,Python,matplotlib,walk,position,np,import 来源: https://blog.csdn.net/kz_java/article/details/120888376