pyqtgraph repeate ticks on x axis

Hello everyone,

Does anyone have an idea how I could use pyqtgraph to repeat the x axis when creating a Graph?
So the x- axis goes from 0-3 and then again from 0-3?

Here is a minimal example:

import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QComboBox, QVBoxLayout, QWidget
import pyqtgraph as pg

class MyWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        # Set window properties
        self.setGeometry(100, 100, 1200, 800)
        self.setWindowTitle("PyQt Example")

        x = [0, 1, 2, 3, 0, 1, 2, 3]
        y = [1, 4, 9, 6, 2, 6, 5, 8]

        self.graphWidget = pg.PlotWidget(self)

        # Setze die Labels für die Achsen
        self.graphWidget.setLabel('left', 'Y-Achse', color='blue')
        self.graphWidget.setLabel('bottom', 'X-Achse', color='green')

        curve1 = self.graphWidget.plot(x, y, pen='b', symbol='o',)

        layout = QVBoxLayout()
        layout.addWidget(self.graphWidget)

        central_widget = QWidget()
        central_widget.setLayout(layout)

        self.setCentralWidget(central_widget)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = MyWindow()
    window.show()
    sys.exit(app.exec_())

Thanks

Nice day

Hi @zeile42 welcome to the forum.

Each position on the x-axis has to have a unique value, otherwise it would be ambiguous where to plot if plotting at position x=0 – there would be multiple x=0 points on the graph.

However, you can display whatever value you want at a given x position using strings. The way to achieve this would be to set a numeric axis of e.g. 0…12 and then set string labels for each point, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2 , 3.

The the user it would appear that the graph x axis repeats, but internally each x-position would have a unique value & could be plotted to uniquely.