dhabbyc
2018-08-16 18:54:18 UTC
Hello,
I've been modifying the Multi axis example using a BarCharItem on the left
axis and a PlotCurveItem in the second. No matter what I do the right plot
always stays behind the left one.
Here is what I'm doing:
*# -*- coding: utf-8 -*-*
*"""*
*Demonstrates a way to put multiple axes around a single plot. *
*(This will eventually become a built-in feature of PlotItem)*
*"""*
*#import initExample ## Add path to library (just for examples; you do not
need this)*
*import pyqtgraph as pg*
*from pyqtgraph.Qt import QtCore, QtGui*
*import numpy as np*
*pg.mkQApp()*
*pw = pg.PlotWidget()*
*pw.show()*
*pw.setWindowTitle('pyqtgraph example: MultiplePlotAxes')*
*p1 = pw.plotItem*
*print p1.scene()*
*l = pg.LegendItem((100,60), offset=(70,30)) *
*l.setParentItem(p1.getViewBox())*
*p1.setLabels(left='axis 1')*
*## create a new ViewBox, link the right axis to its coordinate system*
*p2 = pg.ViewBox()*
*p1.showAxis('right')*
*p1.scene().addItem(p2)*
*p1.getAxis('right').linkToView(p2)*
*p2.setXLink(p1)*
*p1.getAxis('right').setLabel('axis2', color='#0000ff')*
*## Handle view resizing *
*def updateViews():*
* ## view has resized; update auxiliary views to match*
* global p1, p2*
* p2.setGeometry(p1.vb.sceneBoundingRect())*
* ## need to re-update linked axes since this was called*
* ## incorrectly while views had different shapes.*
* ## (probably this should be handled in ViewBox.resizeEvent)*
* p2.linkedViewChanged(p1.vb, p2.XAxis)*
*updateViews()*
*p1.vb.sigResized.connect(updateViews)*
*#one = p1.plot([1,2,4,8,16,32])*
*one = pg.BarGraphItem(x = [0,1,2,3,4,5], height = [100,100,100,100,100,
50], width = 1)*
*two = pg.PlotCurveItem([10,20,40,80,40,20], pen='b')*
*p1.addItem(one)*
*p2.addItem(two)*
*two.setZValue(10000)*
*l.addItem(one, 'one')*
*l.addItem(two, 'two')*
*## Start Qt event loop unless running in interactive mode or using pyside.*
*if __name__ == '__main__':*
* import sys*
* if (sys.flags.interactive != 1) or not hasattr(QtCore,
'PYQT_VERSION'):*
* QtGui.QApplication.instance().exec_()*
Is there a way to fix this?
Thanks in advance.
D.
I've been modifying the Multi axis example using a BarCharItem on the left
axis and a PlotCurveItem in the second. No matter what I do the right plot
always stays behind the left one.
Here is what I'm doing:
*# -*- coding: utf-8 -*-*
*"""*
*Demonstrates a way to put multiple axes around a single plot. *
*(This will eventually become a built-in feature of PlotItem)*
*"""*
*#import initExample ## Add path to library (just for examples; you do not
need this)*
*import pyqtgraph as pg*
*from pyqtgraph.Qt import QtCore, QtGui*
*import numpy as np*
*pg.mkQApp()*
*pw = pg.PlotWidget()*
*pw.show()*
*pw.setWindowTitle('pyqtgraph example: MultiplePlotAxes')*
*p1 = pw.plotItem*
*print p1.scene()*
*l = pg.LegendItem((100,60), offset=(70,30)) *
*l.setParentItem(p1.getViewBox())*
*p1.setLabels(left='axis 1')*
*## create a new ViewBox, link the right axis to its coordinate system*
*p2 = pg.ViewBox()*
*p1.showAxis('right')*
*p1.scene().addItem(p2)*
*p1.getAxis('right').linkToView(p2)*
*p2.setXLink(p1)*
*p1.getAxis('right').setLabel('axis2', color='#0000ff')*
*## Handle view resizing *
*def updateViews():*
* ## view has resized; update auxiliary views to match*
* global p1, p2*
* p2.setGeometry(p1.vb.sceneBoundingRect())*
* ## need to re-update linked axes since this was called*
* ## incorrectly while views had different shapes.*
* ## (probably this should be handled in ViewBox.resizeEvent)*
* p2.linkedViewChanged(p1.vb, p2.XAxis)*
*updateViews()*
*p1.vb.sigResized.connect(updateViews)*
*#one = p1.plot([1,2,4,8,16,32])*
*one = pg.BarGraphItem(x = [0,1,2,3,4,5], height = [100,100,100,100,100,
50], width = 1)*
*two = pg.PlotCurveItem([10,20,40,80,40,20], pen='b')*
*p1.addItem(one)*
*p2.addItem(two)*
*two.setZValue(10000)*
*l.addItem(one, 'one')*
*l.addItem(two, 'two')*
*## Start Qt event loop unless running in interactive mode or using pyside.*
*if __name__ == '__main__':*
* import sys*
* if (sys.flags.interactive != 1) or not hasattr(QtCore,
'PYQT_VERSION'):*
* QtGui.QApplication.instance().exec_()*
Is there a way to fix this?
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 pyqtgraph+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/4c008ac6-3efc-4d56-8d48-3a3c59a5d931%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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 pyqtgraph+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/4c008ac6-3efc-4d56-8d48-3a3c59a5d931%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.