<https://lh3.googleusercontent.com/-te9W_vffBzo/V-1_OwEZx2I/AAAAAAAAABs/lzHQh3ehckkZvhGHRjxPhmXkXgPMr28OgCLcB/s1600/plot.png>
I modified one of the multiple axes examples from the Internet to use in my 
code. I am embedding it into a graphicsView widget promoted to a 
PlotWidget. When I call showGrid I get a grid for two axes when I would 
just prefer just the p1 grid. I am calling the showGrid function on line 29 
of the code below. Any help would be greatly appreciated. 


#imports
from PyQt4 import QtGui
#from PyQt4 import QtCore
import ui_test  #Gui File
import sys
import pyqtgraph as pg

class Gui(QtGui.QMainWindow, ui_test.Ui_MainWindow):        
    def __init__(self):        
        super(self.__class__, self).__init__()        
        self.setupUi(self)  
        self.pg_plot()
        self.updateViews()
        self.plotdata()
        
    
    def pg_plot(self):          
        ## Switch to using white background and black foreground
        self.bepx = 30
        self.bepy = 800
        pg.setConfigOption('background', 'w')
        pg.setConfigOption('foreground', 'k')  
         
        self.p1 = pg.PlotItem()
        
        
        self.graphicsView.setCentralWidget(self.p1)
        self.p1.showGrid(x = True, y = True ,alpha = 0.3)  
        lr = pg.LinearRegionItem([20,40], movable = False, brush = 
'#ffcccc33')  #Set linear region
        self.p1.addItem(lr)
        ## create a new ViewBox, link the right axis to its coordinate 
system
        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('eff', color='g')
        pg.LinearRegionItem([20,40])
        
        ## create third ViewBox. 
        ## this time we need to create a new axis as well.
        self.p3 = pg.ViewBox()
        self.ax3 = pg.AxisItem('right')
        self.p1.layout.addItem(self.ax3,2,3)
        self.p1.scene().addItem(self.p3)
        self.ax3.linkToView(self.p3)
        self.p3.setXLink(self.p1)
        self.ax3.setZValue(-10000)
        self.ax3.setLabel('Power', color='r')    
        
    ## Handle view resizing 
    def updateViews(self):
        ## view has resized; update auxiliary views to match
        
        self.p2.setGeometry(self.p1.vb.sceneBoundingRect())
        self.p3.setGeometry(self.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)
        self.p2.linkedViewChanged(self.p1.vb, self.p2.XAxis)
        self.p3.linkedViewChanged(self.p1.vb, self.p3.XAxis)
       
    def plotdata(self):
        #Plot Datapoints
        self.p1.plot([0,10,20,30,40,50], [1,2,4,8,16,32], pen = 'g')
        self.p2.addItem(pg.PlotCurveItem([0,10,20,30,40,50], 
[10,20,40,80,40,20], pen='b'))
        self.p3.addItem(pg.PlotCurveItem([0,10,20,30,40,50], 
[3200,1600,800,2500,200,100], pen='r'))
        self.bepx = 50
        self.bepy = 1000
    
def main():
    app = QtGui.QApplication(sys.argv) 
    form = Gui() 
    form.show()  
    app.exec_() 
    
if __name__ == '__main__':  # if we're running file directly and not 
importing it
    main()  # run the main function

-- 
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/5ed276e2-e4e4-4552-8e3d-9171fc301761%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to