未定义python hist2d

未定义python hist2d,python,matplotlib,Python,Matplotlib,我想用python绘制一个2d直方图。我在matplotlib wiki上找到了以下示例 from pylab import * x = randn(1000) y = randn(1000)+5 #normal distribution center at x=0 and y=5 hist2d(x,y,bins=40) show() 但是我得到了错误 > Traceback (most recent call last): File "./hist2d_demo.py", lin

我想用python绘制一个2d直方图。我在matplotlib wiki上找到了以下示例

from pylab import *
x = randn(1000)
y = randn(1000)+5

#normal distribution center at x=0 and y=5
hist2d(x,y,bins=40)
show()
但是我得到了错误

> Traceback (most recent call last):   File "./hist2d_demo.py", line 9,
> in <module>
>     hist2d(x,y,bins=40) NameError: name 'hist2d' is not defined
>回溯(最后一次调用):文件“/hist2d\u demo.py”,第9行,
>在
>hist2d(x,y,bins=40)名称错误:未定义名称“hist2d”

有人知道我如何解决这个问题吗?

我刚刚在我的python 2.7.6中复制粘贴了您的代码示例,效果非常好。 我还安装了numpy 1.8.0、scipy 0.9.0和matplotlib 1.3.0。 您的matplotlib版本可能太旧,请通过以下方式进行检查:

import matplotlib
print matplotlib.__version__

没错,我有matplotlib 1.1.1rc,我没有找到hist2d的最低版本。但我试着安装新的Matplotlib,肯定是这样。试试看,如果不行,请告诉我。