Search code examples
pythonpyqtgraph

How to plot some graph with labels?(pyqtgraph/other)


I try to plot some square: A (0,0) B (0,1) C (1,1) D (1,0)

Its easy in using the pyqtgraph:

    plt = pg.plot([0, 0, 1, 1], [0, 1, 1, 0], pen=None, symbol='o')
    plt.showGrid(x=True, y=True)

But how to add labels (like A,B,C,D)?


Solution

  • You need to use setLabel as below :

    import pyqtgraph as pg
    plt = pg.plot([0, 0, 1, 1], [0, 1, 1, 0], pen=None, symbol='o')
    plt.setLabel('left', "A")
    plt.setLabel('bottom', "B")
    plt.setLabel('right', "C")
    plt.setLabel('top', "D")
    plt.showGrid(x=True, y=True)