【Python-BUG】module ‘matplotlib‘ has no attribute ‘plot‘
程序员文章站
2022-03-18 21:37:58
...
问题所在
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)
上一篇: shell编程(一) -变量分析功能来判断是否真的输入
下一篇: php中的钩子是什么意思
推荐阅读
-
module ‘seaborn‘ has no attribute ‘scatterplot‘解决方案
-
AttributeError: module ‘community‘ has no attribute ‘best_partition‘ 问题解决方法
-
module ‘community‘ has no attribute ‘best_partition‘ [已解决]
-
【python】解决AttributeError: module ‘scipy.misc‘ has no attribute ‘toimage‘问题
-
【Tensorflow】Linux下Tensorflow报错:AttributeError: module ‘tensorflow‘ has no attribute ‘xxxx‘
-
AttributeError: 'module' object has no attribute 'main'
-
AttributeError: module 'sklearn' has no attribute 'linear_model'
-
'module' object has no attribute
-
pycharm安装 suds模块报错:AttributeError: module 'pip' has no attribute 'main'
-
python efficientdet AttributeError: module ‘gast‘ has no attribute ‘Num‘