Matplotlib只是给出错误消息 [英] Matplotlib just giving error messages

查看:81
本文介绍了Matplotlib只是给出错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Matplotlib.我以前在这里使用过它,并且运行良好.我正在使用IDLE环境,并且在Matplotlib网站上看到交互模式在IDLE中不起作用,但是在这种情况下应该没有关系.此外,该库似乎也可以导入:

I am trying to use Matplotlib. I have used it here at work before and it ran just fine. I am using the IDLE environ and I read on the Matplotlib website that interactive mode does not work in IDLE, but that should not matter in this case. Also, the library seems to importing just fine:

>>> 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

这篇关于Matplotlib只是给出错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆