I'm plotting a 2D histogram where the x-axis corresponds to a time axis. However, I'm having trouble displaying the x-axis values as the time data I want instead of the index of the 1D arrays. My 2D histogram is composed of 2000 arrays of length 513. I receive the arrays progressively at uncertain times (they are streamed from an external device over USB). I update the image each time a new array is received. Currently the x-axis displays values from 0 to 2000, corresponding to the array index. Instead, I'd like it to display the exact same image, but with time values I record when I receive each array. A simplified version of my code is like this
app = QtGui.QApplication([])
win = QtGui.QMainWindow()
imv = pg.ImageView(view=pg.PlotItem())
img_view = imv.getView()
img_view.invertY(False)
img_view.setLimits(yMin=0, yMax=data.shape[1])
img_view.getAxis("left").setScale(0.5)
win.setCentralWidget(imv)
win.show()
`data` is a 2D list of the data. Every time I get a new array, I insert it into `data` and call `setImage` and call `app.processEvents()`.
imv.setImage(data)
app.processEvents()
I can create an array of the x values I want based on the times (via `clock_gettime(CLOCK_MONOTONIC)` when each array is received), but I don't know how to set the displayed x-axis values to these values. Is there a function to do this? I saw `setLabel`, but it doesn't appear that it does this.
I also know that I can use `setScale`. If you notice, I use this above for the y-axis. However, I can't use this here. The primary reason is that once a full 2000 arrays have been plotted, I restart the plot and plot the next 2000, but I want the time values to continue to increment, not go back to 0. Additionally, it would be slightly misleading since all time values past the current array time would be an estimate, which may or may not be very accurate. If there's a way to set the axis display from an array, I'd also like to do this for the y-axis since it would give me more flexibility there too.