python - PyQt/Matplotlib 动画的最大 fps 是多少?
问题描述
在我的 Python 项目中,使用 PyQt 图形小部件并从第三方硬件中提取数据,我试图最大限度地提高更新速度以显示实时读数。是否有我应该追求的基准,或者它与我可以操纵的另一个自变量有直接关系。
'代码'
#graphing window class, called by each object instantiation
类 MainWindow(QtWidgets.QMainWindow):
def __init__(self,chan,*args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
self.chan=chan
self.graphWidget = pg.PlotWidget()
self.setCentralWidget(self.graphWidget)
self.x = list(range(100)) # 100 time points
self.y = [0 for _ in range(100)] # 100 data points
self.graphWidget.setBackground('w')
self.setWindowTitle("Channel " + (str)(self.chan))
self.setGeometry((500*self.chan), 50, 500, 300)
pen = pg.mkPen(color=(255, 0, 0))
self.data_line = self.graphWidget.plot(self.x, self.y, pen=pen)
#closing the graph window(with the drop down menu)
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.update_plot_data)
self.timer.start()
#Eventual call to IsTriggered()
def update_plot_data(self):
if (adc_list[self.chan].used):
d = adc_list[self.chan].chip.read(f)
data_set[self.chan].append(d)
#d = signal.decimate(d, adc_list[self.chan].downsample_factor)
global clock_divider
global user_scaling
clock_divider[self.chan]+=1
if (clock_divider[self.chan]==clock_divs[self.chan]):
clock_divider[self.chan]=0
self.x = self.x[1:] # Remove the first y element.
a=(self.x[-1]+1)
self.x.append(a)
self.y = self.y[1:] # Remove the first
self.y = np.append(self.y, np.mean(d)*user_scaling[self.chan])
self.data_line.setData(self.x, self.y)
解决方案
推荐阅读
- python - 如何在for循环中修改序列(不是范围)?
- jquery - 下拉雪佛龙不旋转
- firebase - 如何在 BigQuery 中合并 Google Ads 和 Firebase 数据
- android - 无法在华为和三星手机上更改可绘制颜色(色调)
- d3.js - tickSizeOuter 不等于零,但仅 yAxis 的第一个和最后一个刻度显示行
- java - Java 中的急切加载是什么?
- asp.net - EPPlus - 无法从 excel 中获取 NPV 和 IRR 函数的值
- iis - IIS 服务器是不是反映了变化?
- azure-data-factory - AzureDataFactory 如何存储过滤器操作的输出
- java - 如何通过 Springboot 服务的 2 个实例从共享位置并行访问文件?