python - How to enableswap secondary viewbox of plotWidget to listen mouse events in plot area? - Stack Overflow

I have a PlotWidget with several plotDataItems showed. I'm trying to isolate one or several plots,

I have a PlotWidget with several plotDataItems showed. I'm trying to isolate one or several plots, place them up or down in the graph, and use mouse to zoom and scaling over the plot area as I do with the "main group" of plots.

I tried to make a new viewbox and add it to mainGraph plotwidget after pushing a button, and it works. But mouse events seem to be catched in the plotting area ONLY by the main viewbox. I know that I can Y-scale that plot using the wheel over the new axis, but not over the plot area. That's the challenge.

This is the button connected method that I use to create and link the new viewbox to mainGraph:

def rePlotChannelWithAxisRight(self, channel):
    ## create a new ViewBox, link the right axis to its coordinate system
    self.p1 = self.mainGraph.getPlotItem()
    self.p2 = pg.ViewBox()
    self.p1.showAxis('right')
    self.p1.scene().addItem(self.p2)
    self.p1.getAxis('right').linkToView(self.p2)
    self.p2.setXLink(self.p1)
    self.p1.getAxis('right').setLabel('axis2', color='#0000ff')
    self.updateViews()
    self.p1.vb.sigResized.connect(self.updateViews)

    # Remove plot from mainGraph 
    self.mainGraph.removeItem(self.graphPlots[channel.ID])
    # Add plot to secondary viewbox 
    self.p2.addItem(self.graphPlots[channel.ID])

def updateViews(self):
    ## view has resized; update auxiliary views to match
    self.p2.setGeometry(self.p1.vb.sceneBoundingRect())

    self.p2.linkedViewChanged(self.p1.vb, self.p2.XAxis)

Please, any solution for this will be very appreciated.

Thank you in advance.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745650002a4638206.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信