xlinking graphs across different classes (in different docks)

27 views
Skip to first unread message

Alex Schueth

unread,
Jul 11, 2016, 7:01:05 PM7/11/16
to pyqtgraph
I am using the DockArea() functionality in pyqtgraph to plot different graphs on different tabs. I am currently have all of the graphs on one dock xlinked, however I would like to extend that functionality to the other dock so all of the plots are xlinked. Is this possible? Here is a snippet of my code to show what I am trying, but it doesn't seem to be working.

class ThermoWidget(pg.GraphicsLayoutWidget):
     
def __init__(self,*args, **kwargs):
         
super(ThermoWidget, self).__init__(*args, **kwargs)

         
self.p1 = self.addPlot(axisItems = {'bottom': CAxisTime(orientation='bottom')})
         
self.p2 = self.addPlot(axisItems = {'bottom': CAxisTime(orientation='bottom')})

         
self.curve1 = self.p1.plot()
         
self.curve2 = self.p2.plot()

         
self.nextRow()

         
self.p3 = self.addPlot(axisItems = {'bottom': CAxisTime(orientation='bottom')})
         
self.p4 = self.addPlot(axisItems = {'bottom': CAxisTime(orientation='bottom')})

         
self.curve3 = self.p3.plot()
         
self.curve4 = self.p4.plot()

         
self.nextRow()

         
self.p5 = self.addPlot(axisItems = {'bottom': CAxisTime(orientation='bottom')})
         
self.p6 = self.addPlot(axisItems = {'bottom': CAxisTime(orientation='bottom')})

         
self.curve5 = self.p5.plot()
         
self.curve6 = self.p6.plot()

         
self.p1.setXLink(self.p2)
         
self.p2.setXLink(self.p3)
         
self.p3.setXLink(self.p4)
         
self.p4.setXLink(self.p5)
         
self.p5.setXLink(self.p6)

     
def plot(self, data):

         
self.curve1.setData(data)
         
self.curve2.setData(data)
         
self.curve3.setData(data)
         
self.curve4.setData(data)
         
self.curve5.setData(data)
         
self.curve6.setData(data)

          pg
.QtGui.QApplication.processEvents()


class KinemWidget(pg.GraphicsLayoutWidget):
     
def __init__(self,*args, **kwargs):
         
super(KinemWidget, self).__init__(*args, **kwargs)

         
self.p1 = self.addPlot(axisItems = {'bottom': CAxisTime(orientation='bottom')})
         
self.p2 = self.addPlot(axisItems = {'bottom': CAxisTime(orientation='bottom')})

         
self.curve1 = self.p1.plot()
         
self.curve2 = self.p2.plot()

         
self.p1.setXLink(self.p2)
          thermo
=ThermoWidget()
         
self.p2.setXLink(thermo.p6)


     
def plot(self, data):

         
self.curve1.setData(data)
         
self.curve2.setData(data)
          pg
.QtGui.QApplication.processEvents()


Alex Schueth

unread,
Jul 22, 2016, 4:26:47 PM7/22/16
to pyqtgraph
Perhaps I should clarify seeing no responses yet. The key part I'm confused about is if it is possible to reference graphs across classes. In my class KinemWidget I have the following lines: 

          self.p1.setXLink(self.p2)
          thermo
=ThermoWidget()
         
self.p2.setXLink(thermo.p6)

The first line should be straightforward in that I am linking the x-axis of the first graph to the second graph. However, I would also like to link the x-axis of both of those graphs to a graph in another class (line 3). Is this possible? If so is that the correct syntax to accomplish that?

If it is not possible to xlink across classes, is there another creative way to xlink plots in two different tabs?
Reply all
Reply to author
Forward
0 new messages