I am trying to create a little widget using pyqtgraph that updates in real time. I made this work with no problem using a line plot. However, I would like to do this with a bar plot using the addPlot
method in pg.GraphicsWindow
.
Here's the basic setup I have so far:
import pyqtgraph as pg
self.win = pg.GraphicsWindow(title='Spectrum Analyzer')
self.spectrum = self.win.addPlot(
title='SPECTRUM', row=1, col=1
)
# Plot the init data -- I want this to be a bar plot
self.obj = self.spectrum.plot(pen='m', width=3)
# Update data content in plot -- stick in loop
self.obj.setData(data_x, data_y)
I like the rapid features of addPlot
and would rather not use pg.plot().addItem(pg.BarGraphItem())
in a loop due to high latency.
Maybe something like
# initialization
self.obj = pg.BarGraphItem()
self.spectrum.addItem(self.obj)
# update
self.obj.setOpts(...)
?