Discussion:
Updating data
chicago
2011-04-07 14:17:37 UTC
Permalink
Hi there,

I am using guiqwt for the first time and i really like it.
Nonetheless, like one of the other posters, I am struggling a bit with
it as I want to update a curve as new data comes in. Basically, I have
a data source, say an EEG, and I want to update the plot as new data
comes in. Is this possible? Could you be so kind and provide a short
summary of what I have to do to update a plot in realtime?

Thanks,
Ulrich
cormorant
2011-04-08 07:32:16 UTC
Permalink
This works for me:
self.item.set_data(new_x, new_y)
# where "self.item" is instance of guiqwt.curve.CurveItem class.
# and redraw
self.curvewidget.plot.replot()
Post by chicago
Hi there,
I am using guiqwt for the first time and i really like it.
Nonetheless, like one of the other posters, I am struggling a bit with
it as I want to update a curve as new data comes in. Basically, I have
a data source, say an EEG, and I want to update the plot as new data
comes in. Is this possible? Could you be so kind and provide a short
summary of what I have to do to update a plot in realtime?
Thanks,
Ulrich
chicago
2011-04-08 08:40:15 UTC
Permalink
Thanks, that put me on the right track.


class ChartWindow:
def __init__(self, desc):
self.widget = CurveWidget(title=desc)
self.desc = desc
x1 = np.array([0,0])
y1 = np.array([0,0])

self.valueCurve= make.mcurve(x1,y1,'b-')
self.widget.plot.add_item(self.valueCurve)
self.widget.show()

def updateChart(self, wave):
xarray = np.arange(0,len(wave.values))
self.valueCurve.set_data(xarray, np.array(wave.values))
self.widget.plot.replot()


Mind that the chart window has to be initialized and managed by the QT
main thread!

Thanks
Post by cormorant
self.item.set_data(new_x, new_y)
# where "self.item" is instance of guiqwt.curve.CurveItem class.
# and redraw
self.curvewidget.plot.replot()
Post by chicago
Hi there,
I am using guiqwt for the first time and i really like it.
Nonetheless, like one of the other posters, I am struggling a bit with
it as I want to update a curve as new data comes in. Basically, I have
a data source, say an EEG, and I want to update the plot as new data
comes in. Is this possible? Could you be so kind and provide a short
summary of what I have to do to update a plot in realtime?
Thanks,
Ulrich
Continue reading on narkive:
Loading...