matplotlib contourf()引发异常" ValueError:数组太大。"

时间:2014-08-12 16:15:04

标签: python matplotlib

我正在尝试使用3D轮廓绘制数据集(777 x 576)。这似乎工作正常,直到我尝试将轮廓放在3d图下。

from mpl_toolkits.mplot3d import axes3d
from matplotlib import cm, pyplot
import numpy

X,Y = numpy.mgrid[:len(data), :len(data[0])]

fig = pyplot.figure('''figsize=(20, 10), dpi=800''')
ax = fig.gca(projection='3d')
ax.plot_surface(X,
                Y,
                data,
                rstride=100, 
                cstride=100, 
                alpha=0.3, 
                linewidths=(.5,), 
                antialiased=True, 
                )
# cset = ax.contourf(X, Y, data, zdir='z', offset=130, cmap=cm.coolwarm)

ax.set_xlim(800, 0)
ax.set_ylim(0, 600)
ax.set_zlim(130, 170)

plt.show()

也就是说取消注释ax.contourf(...)行会导致以下异常:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python27\lib\lib-tk\Tkinter.py", line 1470, in __call__
    return self.func(*args)
  File "C:\Python27\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 276, in resize
    self.show()
  File "C:\Python27\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 348, in draw
    FigureCanvasAgg.draw(self)
  File "C:\Python27\lib\site-packages\matplotlib\backends\backend_agg.py", line 451, in draw
    self.figure.draw(self.renderer)
  File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "C:\Python27\lib\site-packages\matplotlib\figure.py", line 1034, in draw
    func(*args)
  File "C:\Python27\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py", line 248, in draw
    for col in self.collections]
  File "C:\Python27\lib\site-packages\mpl_toolkits\mplot3d\art3d.py", line 456, in do_3d_projection
    cedge = cedge.repeat(len(xyzlist), axis=0)
ValueError: array is too big.

如果这意味着什么:

len(cedge) == 35656
len(xyzlist) == 8914
35656 * 8914 = 317837584

我需要设置一些东西来容纳我的数据集吗?

0 个答案:

没有答案