Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: module 'matplotlib' has no attribute 'plot' [duplicate]

I am using python 3.6 and while running the below code i am getting as error which says
Traceback (most recent call last): File "C:/Users/Sagar/AppData/Local/Programs/Python/Python36-32/graphfile.py", line 10, in plt.plot(x,y) AttributeError: module 'matplotlib' has no attribute 'plot'

The code is

import matplotlib as plt
x=[]
y=[]
readfile=open("graph.txt","r")
data=readfile.read().split("\n")
for i in data:
     val=i.split(",")
     x.append(int(val[0]))
     y.append(int(val[1]))
plt.plot(x,y)
plt.show()
like image 811
Swapnil Sagar Avatar asked Jan 31 '18 20:01

Swapnil Sagar


1 Answers

The import statement should be like:

 import matplotlib.pyplot as plt
like image 149
Joseloman Avatar answered Nov 12 '22 09:11

Joseloman