python - Matplotlib 只是给出错误信息

标签 python python-2.7 matplotlib

我正在尝试使用 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/

相关文章:

python - 使用 FLask 和 matplotlib 即时生成图像

python - 为什么我调用这些方法时总是出现 "Not found"错误?

python - 安装的 Python 脚本无法导入包模块

python - 更新 matplotlib 中的箭头位置

用于自定义序列类型的 Python re

python - 如何在 linux crontab 中运行 python 程序?

python - 根据柱高绘制 x 轴值的直方图

python - Keras 神经网络为每个输入输出相同的结果

python - 从 Python 中将文件名传递给子进程

python - 从 pandas df 中选择特定列