如何绘制带有标签的图表?(pyqtgraph/other)

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

我尝试绘制一些正方形: 一个(0,0) 乙 (0,1) C (1,1) D(1,0)

使用pyqtgraph很简单:

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

但是如何添加标签(如 A、B、C、D)?

您需要如下使用 setLabel :

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)