Legend items creeping to the right

19 views
Skip to first unread message

Reuben Gann

unread,
Feb 20, 2018, 1:31:06 PM2/20/18
to pyqtgraph
Hi,

My code manages the items in the legend manually. When a new series is plotted, it calls

legend.addItem(self.pointerToPlot, self.legendtext)


and when removing

legend.removeItem(self.legendtext)


After creation, I do not interact with the legend in any other way. This works, but if I repeat this process (adding and removing the same item), the legend item moves to the right a couple of pixels each time. If I print legend.layout.geometry(), this effect can be seen

PyQt5.QtCore.QRectF(0.0, 0.0, 96.0, 120.0)
PyQt5.QtCore.QRectF(0.0, 0.0, 98.0, 120.0)
PyQt5.QtCore.QRectF(0.0, 0.0, 100.0, 120.0)
PyQt5.QtCore.QRectF(0.0, 0.0, 102.0, 120.0)
PyQt5.QtCore.QRectF(0.0, 0.0, 104.0, 120.0)
PyQt5.QtCore.QRectF(0.0, 0.0, 106.0, 120.0)
PyQt5.QtCore.QRectF(0.0, 0.0, 108.0, 120.0)

I suspect the issue lies inside the LegendItem.updateSize function, though I do not immediately see a reason for the behavior I observe.

Anybody have any ideas?

I am using pyqtgraph v 0.10.0 and PyQt 5.6.2 on Windows 7/Anaconda

Thank you
Reply all
Reply to author
Forward
0 new messages