Hello, I have a PlotWidget on which I have added a ViewBox instance on the bottom of the layout. The idea is to place the legend there.
So far I have two issues: 1. The legend box doesnt fit the viewbox height... No matter what I do... I've tried to force the box size, to set manually the widget geometry and nothing works... 2. I havent been able to "center" the legend below the main plot. When I try to manually set the position of it (setPos) i cant compute correctly the appropiate coordinates. If I use the viewbox center minus the coordinates of the center of the legend, the result is biased to the left. Here is an example of what I'm doing: *import pyqtgraph as pg* *from pyqtgraph.Qt import QtCore, QtGui* *import numpy as np* *app = QtGui.QApplication([])* *mw = QtGui.QMainWindow()* *cw = QtGui.QWidget()* *mw.setCentralWidget(cw)* *l = QtGui.QVBoxLayout()* *cw.setLayout(l)* *pw = pg.PlotWidget(name='Plot1')* *l.addWidget(pw)* *vb = pg.ViewBox(parent = pw.plotItem)* *pw.plotItem.layout.addItem(vb, 4, 1, 1, 4)* *lg = pg.LegendItem()* *lg.setParentItem(vb)* *curve = pg.PlotCurveItem(y = np.random.normal(size=100)*1e0)* *pw.plotItem.addItem(curve)* *lg.addItem(curve, 'test')* *mw.show()* *if __name__ == '__main__':* * import sys* * if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):* * QtGui.QApplication.instance().exec_() * Thanks in advance. D. -- You received this message because you are subscribed to the Google Groups "pyqtgraph" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/21f78683-faec-4dac-8b2a-a3d6232ddea3%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
