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()
The import statement should be like:
import matplotlib.pyplot as plt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With