When I imported matplotlib by using only import matplotlib, whether the pyplot was imported or not.
Following is a code to show my problem :
import numpy as np
import matplotlib as plt
print(np.sin(180))
x_sin=np.arange(0, 3*3.14 ,0.1)
print(x_sin)
y_sin=np.sin(x_sin)
print(y_sin)
plt.pyplot.plot(x_sin,y_sin)
When I tried to run this code it gave me the error:
AttributeError: module 'matplotlib' has no attribute 'pyplot'
matplotlibandmatplotlib.pyplotare different modules, simple as that. Note thatmatplotlib.pyplotis a single dotted name, and not an attribute lookup on thematplotlibmodule.importstatement,matplotlib.pyplotisn't an attribute lookup. If you try to usematplotlib.pyplotlater in an expression, that'll be an attribute lookup.