I have a feeling that I'm missing something obvious here, but I didn't find anything useful on the internet.
I have an application that displays a signal using pyqtgraph. The signal has 1000 samples representing values in 0 - 0.5 range.
Plotting it with correct X-axis values is simple - I'm just making a linspace
with correct range and number of elements and use it as x
in plot
.
But how to do the same for the ImageItem
that is inside a PlotWidget
? It uses number of elements as its X-axis, and I wasn't able to figure out how to tell it to use correct values.
Take a look at the screenshot - I need to use the same X-axis values for images as for the plots below.
For the relevant bits of code:
First, I create my X-values:
self.xval_h = numpy.linspace(0, 0.5, len(self.spectrum_h[-1]))
self.xval_v = numpy.linspace(0, 0.5, len(self.spectrum_v[-1]))
And for the update of the plots and images:
def update_spectrum(self):
self.HSpectrum.plot(self.xval_h, self.spectrum_h[-1], clear=True)
self.VSpectrum.plot(self.xval_v, self.spectrum_v[-1], clear=True)
def update_trace(self):
self.image_h.setImage(numpy.array(self.spectrum_h).T)
self.image_v.setImage(numpy.array(self.spectrum_v).T)
So, the question boils down to how do I use my xval
s with ImageItem
(or PlotWidget
that contains the ImageItem
)?
Many thanks for help!