Hi pyqtgraph users
I am currently creating a line plot using the following sequence:
app = pg.QtGui.QApplication([])
main_window = pg.QtGui.QMainWindow()
main_window.setGeometry(10,40,1380,800)
rhs_widget = pg.QtGui.QWidget(main_window)
rhs_widget.setGeometry(1200,0,180,800)
plot_window = pg.GraphicsLayoutWidget(main_window)
plot_window.setGeometry(0,0,1200,800)
I then add plot panels to the main_window using, for example:
p1 = plot_window.addPlot(col=1,row=1)
p1.setTitle('<font size="3">Active Power</font>',**titleStyle)
p1.setLabel(axis='left',text='<font size="3">Power (kW) </font>')
p1.setLabel(axis='top',)
p1.setLabel(axis='bottom',text='<font size="3">Time elapsed (s)</font>')
p1.setYRange(00,2500)
a = p1.getAxis('top')
a.tickFont = b
a.showValues='false'
a = p1.getAxis('bottom')
a.tickFont = b
p1.showAxis('left')
a = p1.getAxis('left')
a.tickFont = b
p1.showAxis('right')
a = p1.getAxis('right')
a.tickFont = b
p1.showLabel('left',show=True)
p1.showLabel('right',show=True)
p1.showGrid(x=True,y=True,alpha=0.5)
p1.addLegend(size=(10,30),offset=(10,10))
After the plot panels are created, I add the curves with, for example:
curve1 = p1.plot(data1,pen={'color':(0,0,255),'width':0.6},
symbolPen=(0,0,255),symbolBrush=(0,0,255),symbolSize=4,
name='WTG1',symbol='o')
curve2 = p1.plot(data2,pen={'color':(0,255,0),'width':0.6},
symbolPen=(0,255,0),symbolBrush=(0,255,0),symbolSize=4,
name='WTG2',symbol='o')
curve3 = p1.plot(data3,pen={'color':(255,0,0),'width':0.6},
symbolPen=(255,0,0),symbolBrush=(255,0,0),symbolSize=4,
name='WTG3',symbol='o')
The legend is added, all the plots work, but the legend font size needs adjustment. Can anybody help?
It seems that the size parameter in p1.addLegend(size=(10,30),offset=(10,10)) does not change anything. Can I change the font size without having to resort to manually creating the legend and adding individual legend items?
Resulting image is attached...
Thanks!
Jan
I tried