Change x-axis marks in pyqtgraph

Viewed 32

I have a graph in an application with pyqt5. The graph is made with pyqtgraph like this: plotWidget = pg.PlotWidget() I use it to plot audio signals, but the x-axis marks the labels by default. How can I put other labels different from the ones that pyqtgraph puts? The following line is the one I use to graph: elf.curve = self.graphWidget.plot(self.signal) This is how it shows an audio: enter image description here

I need is to change the marks of the x axis

1 Answers

@absolute-madness is basically correct; if you don't pass an explicit set of x values to your plot, PyQtGraph will just number them starting at 0. I recommend using linspace to produce an array with values across a range, but whatever you use will probably work. I expect your audio samples have time values for their x coordinate, and if you don't already have that data, what you want is to incorporate your sample rate into that range (and maybe use a DateAxisItem to display them, though likely you'll just want to have a 0 time at the start of your graph, rather than a specific date and time). Then just pass the x values into the .plot(self.time_vals, self.signal) call.

Related