Pyqtgraph legend

40 views
Skip to first unread message

Azar Jabbarli

unread,
Jul 6, 2020, 9:56:24 AM7/6/20
to pyqtgraph
How can I set or change the position of the legend in pyqtgraph?

Patrick

unread,
Jul 6, 2020, 10:28:15 PM7/6/20
to pyqtgraph
Hi,

If you create the legend object and add it manually, then you can specify the position and size. There's an example of that in the Legend example code. Something like:

#legend = plt.addLegend() # Don't use this, instead create and populate legend manually
= pg.LegendItem((100,60), offset=(70,30))  # args are (size, offset)
l
.setParentItem(plt.graphicsItem())   # Note we do NOT call plt.addItem in this case

Patrick
Reply all
Reply to author
Forward
0 new messages