簡體   English   中英

如何將文本添加到 pyqtgraph 中的 plot 中,例如 matplotlib.plot.text()

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

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))

我試過這個,但它在我的情況下不起作用,有誰知道如何在 pyqtgraph 中做到這一點? 謝謝

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM