小编pxc*_*pxc的帖子

Matplotlib OverflowError:分配了太多块

我正在策划三组约20个时间序列.每个时间序列有180万点,我正在分别绘制它们.为了减少执行时间(因为我发现figure()函数非常耗时),我只打开一个数字,绘图然后清理下一个时间序列.就像是:

import matplotlib.pyplot as plt

fig = plt.figure() # open a figure for plotting
for v in range(nfigs):
    # here I build the x and y vectors from the raw data
    # and also the figname string
    plt.plot(x, y, linewidth=0.3)
    plt.title('a title')
    plt.xlabel('x-label')
    plt.ylabel('y-label')
    plt.grid()
    plt.draw()
    plt.savefig(figname)
    plt.clf()
plt.close() # close the figure after the job is done
Run Code Online (Sandbox Code Playgroud)

除了特别是所有数据集中的所有数据集之外,所有绘图都保存正常,这给出了以下错误(编辑文件路径以保护隐私):

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~\AppData\Local\Continuum\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 540, in runfile
    execfile(filename, namespace)
  File "batch.py", …
Run Code Online (Sandbox Code Playgroud)

plot matplotlib python-2.7 python-3.x

12
推荐指数
2
解决办法
1万
查看次数

标签 统计

matplotlib ×1

plot ×1

python-2.7 ×1

python-3.x ×1