Hello Patrick, You were right. It was enough to set the "secondary" viewbox zvalue to 0 and put the line above the bar (setting z value again). By default vieboxes have a zvalue of -100. Now I have to correct a related issue for "clicked" items (I need to know if I'm clicking the bar plot or the line plot), but I have it figured out.
Thank you. D. On Thu, Aug 16, 2018 at 11:15 PM Patrick <[email protected]> wrote: > Try changing > *two.setZValue(10000)* > to > *p2.setZValue(10000)* > > I think maybe the z-order of the plots inside each ViewBox might be > independent from the z-order of the actual ViewBoxes? So this puts one > ViewBox behind the other, while you might have just been playing with the > z-order within each ViewBox separately? > > > On Friday, 17 August 2018 04:24:18 UTC+9:30, dhabbyc wrote: >> >> 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. >> >> > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/pyqtgraph/4c64576d-fbf4-43e2-9f87-a66235a8b552%40googlegroups.com > <https://groups.google.com/d/msgid/pyqtgraph/4c64576d-fbf4-43e2-9f87-a66235a8b552%40googlegroups.com?utm_medium=email&utm_source=footer> > . > 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/CAKzfFOTeuNULUeehiM%3Du6tKHEXbCYH%3DmGoRRcxHU%2BzOAuhnNWA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
