Nobody has the com8 device to try your code. Just start to make the app it
this way, please:



*import numpy as npimport pyqtgraph as pg*























*import serialapp = pg.Qt.QtGui.QApplication([]) p =
pg.plot()p.setWindowTitle('live plot from serial')curve = p.plot()data =
[0]raw=serial.Serial("COM8",115200)while p.isVisible():    line =
raw.readline()    line=str(line)    line=line.split(' ')    if
len(line)>4:        line=line[2]        line=int(line)    else:
continue           data.append(line)    xdata = np.array(data,
dtype='int32')    curve.setData(xdata)    app.processEvents() *



On Sat, Jul 6, 2019 at 3:12 PM WILMER CONTRERAS SEPULVEDA <
[email protected]> wrote:

>
> [image: image.png]Hi Guys, how are you?
>
> I am so sorry, this is the new version of my code, I am trying to plot
> just one graph with the data which come from the serial port (PORT8),
> This is the code:
>
> from pyqtgraph.Qt import QtGui, QtCore
> from pyqtgraph.ptime import time
> import numpy as np
> import pyqtgraph as pg
>
> import serial
>
> app = QtGui.QApplication([])
>
> p = pg.plot()
> p.setWindowTitle('live plot from serial')
> curve = p.plot()
> data = [0]
> raw=serial.Serial("COM8",115200)
>
> def leer():
>     while True:
>         line = raw.readline()
>         line=str(line)
>         line=line.split(' ')
>         if len(line)>4:
>             line=line[2]
>             line=int(line)
>             return(line)
>         else:
>             continue
>
> def update():
>     global curve, data
>     data.append(int(leer()))
>     curve.setData(data)
>     app.processEvents()
>
> timer = QtCore.QTimer()
> timer.timeout.connect(update)
> timer.start(50)
>
> if __name__ == '__main__':
>     import sys
>     if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
>         QtGui.QApplication.instance().exec_()
>
> raw.close()
>
> And I always get the same answer from the program:
> [image: image.png]
> El sáb., 6 jul. 2019 a las 16:29, <[email protected]> escribió:
>
>> Hi again,
>>
>> I have no your serial device, but your app should looks like:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *import pyqtgraph as pgimport randomapp = pg.Qt.QtGui.QApplication([]) p
>> = pg.plot()p.setWindowTitle('live plot from random')curve = p.plot()data =
>> [0]while p.isVisible():    line = random.randint(0, 255)
>> data.append(int(line))    xdata = np.array(data, dtype='int32')
>> curve.setData(xdata)    app.processEvents()*
>>
>>
>>
>> So you could start with this code:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *import numpy as npimport pyqtgraph as pgimport serialapp =
>> pg.Qt.QtGui.QApplication([]) p = pg.plot()p.setWindowTitle('live plot from
>> serial')curve = p.plot()data = [0]raw=serial.Serial("COM8",115200)while
>> p.isVisible():    line = raw.readline()    line=str(line)
>> line=line.split(' ')    if len(line)>4:        line=line[2]
>> line=int(line)    else:        continue           data.append(int(line))
>> xdata = np.array(data, dtype='int32')    curve.setData(xdata)
>> app.processEvents()*
>>
>>
>> Next thing is probably to implement Marc's idea of initialization of a
>> larger array.
>>
>> Cheers,
>> Vasilije
>>
>>
>>
>> On Sat, Jul 6, 2019 at 10:16 AM Marc Le Roy <[email protected]> wrote:
>>
>>> I would add that this line of code is highly inefficient since a new
>>> array of increasing size is created at each update:
>>> xdata = np.array(data, dtype='float64')
>>>
>>> I would allocate a large array at initialization, and if required
>>> increase its size using numpy.ndarray.resize with a strategy avoiding to do
>>> it too frequently.
>>>
>>> Marc
>>>
>>> --
>>> 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/8689f39f-b9d5-490e-947d-e7476a96cf25%40googlegroups.com
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> 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/CAD_qyJqQ%3D_iXpxVb5sKiQSAY9y_14PnA3Zm1wu2tPcBXaentZg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/pyqtgraph/CAD_qyJqQ%3D_iXpxVb5sKiQSAY9y_14PnA3Zm1wu2tPcBXaentZg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
>
> *Wilmer Contreras Sepulveda*
>
> *Grupo de Investigación en Desarrollo de Microelectronica Aplicada*
> *Universidad Francisco de Paula Santander *
>
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
>  Virus-free.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
> <#m_3753026936166191006_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> --
> 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/CAOYqKJ7xz_Xy4aKUGZkXG%2B9o15OU0j2Jmnpw_QxMgA_QymwoWA%40mail.gmail.com
> <https://groups.google.com/d/msgid/pyqtgraph/CAOYqKJ7xz_Xy4aKUGZkXG%2B9o15OU0j2Jmnpw_QxMgA_QymwoWA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAD_qyJqot%3D1hW_AAPgo1dRGA%2BnwXoxd3iqpP%2BN4eQ3-9dqbDFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to