admin管理员组文章数量:1435859
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.
版权声明:本文标题:python - How to enableswap secondary viewbox of plotWidget to listen mouse events in plot area? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745650002a2668371.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论