matplotlib图数组大小限制? [英] matplotlib plot array size limit?

查看:88
本文介绍了matplotlib图数组大小限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个程序,每隔半秒左右从串行端口上的设备检索数据.然后将该数据附加到设置数据点的数组中,然后更新绘图.一切正常,直到它运行了一个小时左右,然后程序停止响应.

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.

推荐答案

使用下面的代码,我能够让 matplotlib 显示一千万个点的简单图形.我怀疑问题不在于阵列大小.

Using the code below I was able to get matplotlib to show a simple graph of ten million points. 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()

这篇关于matplotlib图数组大小限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆