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.
For more options, visit https://groups.google.com/d/optout.