How to add text into a plot in pyqtgraph like matplotlib.plot.text()

Viewed 36

Like the title said, I want to add a text into a graph which I used pyqtgraph to plot, but I didn't find any function like matplotlib.plot.text() which I could set the text and even position in the graph.

        self.plt_1.setLabel('left', 'CDF')
        self.plt_1.setLabel('bottom', 'Delay', units='ms')
        self.plt_1.setXRange(0, 200)
        self.plt_1.setYRange(0, 1)
        self.plt_1.setWindowTitle('DL CDF Curve')
        self.plt_1.setMouseEnabled(x=False, y=False)
        self.plt_1.setMenuEnabled(False)
        self.plt_1.setText(30, 20, str(self.x_dl_5g_flag))

I tried this, but it doesn't work in my case, does anyone know how to do it in pyqtgraph? thanks

1 Answers
self.text = pg.TextItem(str(self.x_dl_5g_flag))
self.plt_1.addItem(self.text)
self.text.setPos(30,20)
Related