Reputation: 22030
I am using python 3.6 and a learner. Below is a simple code of a sin wave.
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-10 , 10, 100)
y = np.sin(x)
plt.plot(x, y, marker="x")
I am receiving the error "AttributeError: module 'matplotlib' has no attribute 'plot'" Any help would be appreciated.
Upvotes: 24
Views: 190596
Reputation: 587
Try this simple step.
use pyplot using below import statement when importing matplotlib library.
import matplotlib.pyplot as plt
Upvotes: 25
Reputation: 717
Have you installed matplotlib properly? I added an extra line to your code to show the plot. This code works properly in Visual Studio after installing the matplotlib library.
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-10 , 10, 100)
y = np.sin(x)
plt.plot(x, y, marker="x")
plt.show()
Upvotes: 38