I want to display xticks only at the locations of data points (so the xticks == wavelengths). How can I do this?
Here is my code:
from PyQt6.QtWidgets import QApplication
import pyqtgraph as pg
app = QApplication([])
wavelengths = [610, 680, 730, 760, 810, 860]
data = [239.23, 233.81, 187.27, 176.41, 172.35, 173.78]
pw = pg.plot(wavelengths, data, symbol="o")
pw.getPlotItem().getAxis('bottom').setTicks([wavelengths])
app.exec()
I tried using AxisItem.setTicks(), but it results in an error:
for val, strn in level:
TypeError: cannot unpack non-iterable int object
Traceback (most recent call last):
File "/home/jure/.local/share/virtualenvs/serial-plotting-gui-dWOiQ7Th/lib/python3.10/site-packages/pyqtgraph/graphicsItems/AxisItem.py", line 608, in paint
specs = self.generateDrawSpecs(painter)
File "/home/jure/.local/share/virtualenvs/serial-plotting-gui-dWOiQ7Th/lib/python3.10/site-packages/pyqtgraph/graphicsItems/AxisItem.py", line 936, in generateDrawSpecs
P.S. I also tried this SO answer, but it doesn't work for me