def addAxis(self,plot,**args):
"""
Add an axis on the right side
.. tabularcolumns:: |p{3cm}|p{11cm}|
=============== ============================================================================================
**Arguments**
=============== ============================================================================================
plot pyqtgraph.PlotWidget
*args
1. label Label of the new axis
=============== ============================================================================================
:return: pg.ViewBox
"""
p3 = pg.ViewBox()
ax3 = pg.AxisItem('right')
plot.plotItem.layout.addItem(ax3, 2, 3+len(plot.axisItems))
plot.plotItem.scene().addItem(p3)
ax3.linkToView(p3)
p3.setXLink(plot.plotItem)
ax3.setZValue(-10000)
if args.get('label',False):
ax3.setLabel(args.get('label',False), color=args.get('color','#ffffff'))
p3.setGeometry(plot.plotItem.vb.sceneBoundingRect())
p3.linkedViewChanged(plot.plotItem.vb, p3.XAxis)
## Handle view resizing
Callback = functools.partial(self.updateViews,plot)
plot.getViewBox().sigStateChanged.connect(Callback)
plot.viewBoxes.append(p3)
plot.axisItems.append(ax3)
self.plots2D[p3]=[] # TODO do not consider a new axis as a plot. simply make it a part of the axisItems array of the main plot
return p3
评论列表
文章目录