欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

matplotlib中scatter报错module 'matplotlib' has no attribute 'scatter'

程序员文章站 2022-03-29 17:53:23
...

错误:

D:\pyPro\graph_recognation\venv\Scripts\python.exe D:/pyPro/graph_recognation/studyNew/huigui/simple_liner_regression.py
Traceback (most recent call last):
  File "D:/pyPro/graph_recognation/studyNew/huigui/simple_liner_regression.py", line 9, in <module>
    plt.scatter(x_data,y_data)
AttributeError: module 'matplotlib' has no attribute 'scatter'

原因:

导入包时用的是 

import matplotlib as plt

改为

import matplotlib.pyplot as plt
相关标签: python 解决问题