运行numpy的Meshgrid时的MemoryError [英] MemoryError when running Numpy Meshgrid
问题描述
我的 8823 数据以x点,y坐标。我试图遵循<一个答案href=\"http://stackoverflow.com/questions/2369492/generate-a-heatmap-in-matplotlib-using-a-scatter-data-set\">how得到一个分散的数据集是psented作为热图重新$ P $但是当我经过
I have 8823 data points with x,y coordinates. I'm trying to follow the answer on how to get a scatter dataset to be represented as a heatmap but when I go through the
X,Y = np.meshgrid(X,Y)
我的数据数组的指令,我得到的MemoryError
。我是新来numpy的和matplotlib和我基本上是试图通过调整例子我能找到运行此。
instruction with my data arrays I get MemoryError
. I am new to numpy and matplotlib and am essentially trying to run this by adapting the examples I can find.
下面就是我建立了我的数组从已保存他们一个文件:
Here's how I built my arrays from a file that has them stored:
XY_File = open ('XY_Output.txt', 'r')
XY = XY_File.readlines()
XY_File.close()
Xf=[]
Yf=[]
for line in XY:
Xf.append(float(line.split('\t')[0]))
Yf.append(float(line.split('\t')[1]))
x=array(Xf)
y=array(Yf)
有没有我的数组的一个问题?同样的code工作投入这个例子时候,但我不太肯定。
为什么我得到这个的MemoryError,我该如何解决这个问题?
Why am I getting this MemoryError and how can I fix this?
推荐答案
您调用 meshgrid
需要大量的内存 - 它产生两个8823 * 8823的浮点阵列。他们每个人都约为0.6 GB。
Your call to meshgrid
requires a lot of memory -- it produces two 8823*8823 floating point arrays. Each of them are about 0.6 GB.
但你的屏幕不能显示反正(和你的眼睛不能真正处理)这么多的信息,所以你也许应该想想办法,你做到这一步之前,您的数据平滑的东西更合理像1024 * 1024
But your screen can't show (and your eye can't really process) that much information anyway, so you should probably think of a way to smooth your data to something more reasonable like 1024*1024 before you do this step.
这篇关于运行numpy的Meshgrid时的MemoryError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!