简体   繁体   English

matplotlib图数组大小限制?

[英]matplotlib plot array size limit?

I've created a program that retrieves data from a device on the serial port every half second or so. 我创建了一个程序,每隔半秒左右从串行端口上的设备检索数据。 It then appends that data to the array that sets the data points and then updates the plot. 然后将数据追加到设置数据点的数组中,然后更新绘图。 Everything goes fine until it's been running for an hour or so, at which point the program stops responding. 一切正常,直到运行了一个小时左右,此时程序停止响应。

Does anyone know if there is a size limit for this array? 有人知道该数组是否有大小限制吗? If anyone has any ideas on handling a data set that could be millions of points, I would love to hear your thoughts. 如果有人对处理可能数以百万计的数据集有任何想法,我很想听听您的想法。

Using the code below I was able to get matplotlib to show a simple graph of ten million points. 使用下面的代码,我能够获得matplotlib来显示一千万点的简单图形。 I suspect the problem isn't with the array size. 我怀疑问题不在于阵列大小。

import numpy as np
import matplotlib.pyplot as plt
import random

nsteps = 10000000
draws = np.random.randint(0,2,size=nsteps)
steps = np.where(draws>0,1,-1)
walk = steps.cumsum()
plt.plot(np.arange(nsteps), np.array(walk), 'r-')
plt.title("Big Set Random Walk with $\pm1$ steps")
plt.show()

There seems to be a some limit. 似乎有一些限制。 I just tried 我刚试过

import pylab
import numpy as np

n = 10000000 # my code works fine for n = 1000000

x = np.random.normal(0,1,n)

pylab.plot(x)

pylab.show()

And got the following error: 并得到以下错误:

OverflowError: Agg rendering complexity exceeded. Consider downsampling or decimating your data.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM