我正在尝试使用 Matplotlib。我以前在这里工作时用过它,运行得很好。我正在使用 IDLE 环境,我在 Matplotlib 网站上读到交互模式在 IDLE 中不起作用,但在这种情况下应该无关紧要。此外,该库似乎可以正常导入:
>>> import numpy as np
>>> import matplotlib as plt
>>> x = np.arange(0,3 * np.pi, 0.1)
>>> y = np.sin(x)
>>> plt.plot(x,y)
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
plt.plot(x,y)
AttributeError: 'module' object has no attribute 'plot'
>>> plt.show()
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
plt.show(x,y)
AttributeError: 'module' object has no attribute 'show'
最佳答案
改变
import matplotlib as plt
到
import matplotlib.pyplot as plt
关于python - Matplotlib 只是给出错误信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34139163/