我想在pyqtgraph中标记一些位置
这是代码
def set_history_arrow(self):
print(f"===> up: {len(self.up)} down: {len(self.down)}")
for up in self.up:
print("up", self.up.index(up))
up_arrow = pg.TextItem('↑', fill=(255, 0, 0))
self.plot_widget.addItem(up_arrow)
up_arrow.setPos(up, self.data[up])
for down in self.down:
print("down", self.down.index(down))
down_arrow = pg.TextItem("↓", fill=(0, 238, 118))
self.plot_widget.addItem(down_arrow)
down_arrow.setPos(down, self.data[down])
数据总和为:41363
他们的数量
===> up: 4259 down: 2559
它执行起来很慢
我怎样才能提高速度
如果您有大量文本,那么使用QPainter.drawTexthttp://doc.qt.io/qt-5/qpainter.html#drawText更直接地呈现文本可能会使您受益匪浅
PyQtGraph中有一个在此处绘制自定义图形的示例:https://github.com/pyqtgraph/pyqtgraph/blob/master/examples/customGraphicsItem.py
该示例没有显示如何绘制文本,这本身也不是一件小事
这要复杂得多,@somewheve的建议可能更容易实施
只要使用
ScatterPlotItem
就行了相关问题 更多 >
编程相关推荐