remove this line
self.p1.showGrid(x = True, y = True ,alpha = 0.3)  

and use this 

self.p1.getAxis("left").setGrid(255)







On Thursday, 29 September 2016 17:03:31 UTC-4, MudloggerMike wrote:
>
>
> <https://lh3.googleusercontent.com/-43mjlS_ftvM/V-2BZ3fBIpI/AAAAAAAAAB4/JtUbgQ22fwQyvOUp42oX-kRdGqIdXJZ_ACLcB/s1600/plot.png>
> I modified the code from one of the multiple axes plot examples that I 
> found on the Internet. The plot is embedded in a graphicsView widget that I 
> promoted to a PlotWidget. When I call showGrid for the p1 axis (as shown on 
> line 21 in the code below). I end up with a grid for both p1 and p2 axes. I 
> am sure there is a way to plot just the grid for p1. I've looked through 
> all of the docs and posts and can't find anything about this. 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/06ab03c6-032b-4e33-bfb8-67d01b8c937e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to