谢谢你的回答,经过测试,我使用你的建议之后,发现使用"self.plot.setData(x, y)"之后,发现pyqt5界面上之前的曲线不能保存,查阅了pyqtgraph的文档之后,发现文档显示:setData(*args, **kargs)[source] Clear any data displayed by this item and display new data. See __init__() for details; it accepts the same arguments.使用setData会清除之前加载的数据,这样就不能检索之前的数据了,因为我的软件需要使用"LinearRegionItem"选择指定区间的数据.
<https://fanyi.baidu.com/translate?aldtype=16047&query=%E8%B0%A2%E8%B0%A2%E4%BD%A0%E7%9A%84%E5%9B%9E%E7%AD%94%2C%E7%BB%8F%E8%BF%87%E6%B5%8B%E8%AF%95%2C%E6%88%91%E4%BD%BF%E7%94%A8%E4%BD%A0%E7%9A%84%E5%BB%BA%E8%AE%AE%E4%B9%8B%E5%90%8E%2C%E5%8F%91%E7%8E%B0&keyfrom=baidu&smartresult=dict&lang=auto2zh###> Thank you for your answer. After testing, I used your suggestion and found that“ self.plot.setData (x, y) "after that, it is found that the previous curve on the pyqt5 interface cannot be saved. After consulting the document of pyqtgraph, it is found that: SetData (* args, * * kargs) [source] Clear any data displayed by this item and display new data. See __ init__ () for details; it accepts the same arguments 在2020年11月26日星期四 UTC+8 上午10:14:36<Patrick> 写道: > Hi, > > I'm guessing you are calling self.plotWidget.plot(x, y) a lot, which > creates a new plot item each time. You should instead make one plot, and > then use .setData(x, y) to update the existing plot with the new data. > > self.plot = self.plotWidget.plot() > # .... later, when data is received > self.plot.setData(x, y) > > Patrick > > On Thursday, 26 November 2020 at 12:07:46 pm UTC+10:30 [email protected] > wrote: > >> >> >> >> >> <https://fanyi.baidu.com/translate?aldtype=16047&query=%E4%B8%BA%E4%BB%80%E4%B9%88%E4%BD%BF%E7%94%A8pyqtgrph%E7%94%BB%E5%9B%BE%E7%9A%84%E6%97%B6%E5%80%99%2C%E7%94%B5%E8%84%91%E7%9A%84%E5%86%85%E5%AD%98%E4%BC%9A%E9%9A%8F%E7%9D%80%E6%95%B0%E6%8D%AE%E9%87%8F%E7%9A%84%E5%A2%9E%E5%8A%A0%E8%80%8C%E5%A2%9E%E5%8A%A0.%3F&keyfrom=baidu&smartresult=dict&lang=auto2zh#%23%23> >> 最近使用pyqtgraph遇到问题了,问题表现在,我写了个上位机记录单片机通过串口发给电脑的数据,并将数据存入数据库,问题就在于当我用上位机从数据库中读取保存的数据,并且用pyqtgraph显示出来的时候,随着数据量的增多,电脑内存占用会逐渐加大,直到最后爆掉,我试过屏蔽掉self.plotWidget_ted.plot(y=b, >> >> x=a, >> pen='b')这句话,也就是说不画图,内存就不会有变化了,请问是什么原因导致的呢,是画图的时候,把那些点写入到系统内存里了吗,我上位机在读取数据的时候是循环读取,循环加载,加载完成,会清除掉已经读取的数据, >> >> <https://fanyi.baidu.com/translate?aldtype=16047&query=%E4%B8%BA%E4%BB%80%E4%B9%88%E4%BD%BF%E7%94%A8pyqtgrph%E7%94%BB%E5%9B%BE%E7%9A%84%E6%97%B6%E5%80%99%2C%E7%94%B5%E8%84%91%E7%9A%84%E5%86%85%E5%AD%98%E4%BC%9A%E9%9A%8F%E7%9D%80%E6%95%B0%E6%8D%AE%E9%87%8F%E7%9A%84%E5%A2%9E%E5%8A%A0%E8%80%8C%E5%A2%9E%E5%8A%A0.%3F&keyfrom=baidu&smartresult=dict&lang=auto2zh#%23%23> >> >> Recently, I encountered a problem in using pyqtgraph. The problem is that >> I wrote a PC to record the data sent to the computer by the MCU through the >> serial port, and stored the data in the database. The problem is that when >> I use the upper computer to read the saved data from the database and >> display it with pyqtgraph, with the increase of the amount of data, the >> computer memory occupation will gradually increase, until it finally >> bursts, I tried to block it self.plotWidget_ ted.plot (y = B, x = a, pen'b >> '), that is to say, without drawing, the memory will not be changed. What >> is the reason for that? When drawing, did those points be written into the >> system memory? When reading the data, my upper computer would read the data >> circularly. After loading, the data would be cleared, >> > -- You received this message because you are subscribed to the Google Groups "pyqtgraph" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/f54ccd11-fe7e-4b1c-8aca-e685eb90db39n%40googlegroups.com.
