How to add legends horizontally in python

Viewed 66

I was plotting some data. When I add the legends, it is displayed vertically. How can I show it horizontally on top of plot. The library used pyqtgraph..

Image: https://i.stack.imgur.com/dwwmF.jpg

thank you in advance

BR

2 Answers

I remember there being an angle feuture where you can set it to the degrees you want if you look in the library with all the functions

Look up the docs for LegendItem:

colCount : Specifies the integer number of columns that the legend should be divided into. The number of rows will be calculated based on this argument. This is useful for plots with many curves displayed simultaneously. Default: 1 column.

In your code create a LegendItem with the number of columns that you need. Then call legend_item.addItem with each of your PlotItems and a name.

Related