pyqtgraph: How to link two PlotWidget windows to show the same plot?












0















I am developing an orbital analysis tool using PyQT5 and pyqtgraph!



See: https://github.com/3fon3fonov/trifon



My tool has a plotting area with ~15 plots shown in different tab windows, which show different aspects of the data analysis.



The tool it self is assembled with the Designer-qt5, while the QGraphicView widgets are promoted to pyqtgraphs's PlotWidgets



For example in the gui.py I initialize the plots like this:



def initialize_plots(self):
global p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,pe
p1 = self.graphicsView_timeseries_RV
p2 = self.graphicsView_timeseries_RV_o_c
p3 = self.graphicsView_timeseries_phot
p4 = self.graphicsView_timeseries_phot_o_c
p5 = self.graphicsView_timeseries_activity
p6 = self.graphicsView_timeseries_correlations
# ...
pe = self.graphicsView_extra_plot
# ...


so p1-p6 in this case are different PlotWidget objects on which I add Items/Plot data, i.e. p1.plot(x,y), p1.addItem(), etc.



What I want is to link pe to any of p1-p6!. pe is an extra plot so the user can choose from those already available/created.
Thus the user can select which plot he/she wants to see next to the main plot.



Lets imagine that the ComboBox dropdown menu selects between p1-p6 objects, so



pe = p1, or later: pe = p4



for example.



Is there any way this to be done with PyQtgraph?



I really tried all kind things in the last two weeks and nothing seems to work.



I am aware of the



pe.setXLink(p1)
pe.setYLink(p2)


but this only links the axes not the plot object itself. It doesn't work for me.










share|improve this question





























    0















    I am developing an orbital analysis tool using PyQT5 and pyqtgraph!



    See: https://github.com/3fon3fonov/trifon



    My tool has a plotting area with ~15 plots shown in different tab windows, which show different aspects of the data analysis.



    The tool it self is assembled with the Designer-qt5, while the QGraphicView widgets are promoted to pyqtgraphs's PlotWidgets



    For example in the gui.py I initialize the plots like this:



    def initialize_plots(self):
    global p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,pe
    p1 = self.graphicsView_timeseries_RV
    p2 = self.graphicsView_timeseries_RV_o_c
    p3 = self.graphicsView_timeseries_phot
    p4 = self.graphicsView_timeseries_phot_o_c
    p5 = self.graphicsView_timeseries_activity
    p6 = self.graphicsView_timeseries_correlations
    # ...
    pe = self.graphicsView_extra_plot
    # ...


    so p1-p6 in this case are different PlotWidget objects on which I add Items/Plot data, i.e. p1.plot(x,y), p1.addItem(), etc.



    What I want is to link pe to any of p1-p6!. pe is an extra plot so the user can choose from those already available/created.
    Thus the user can select which plot he/she wants to see next to the main plot.



    Lets imagine that the ComboBox dropdown menu selects between p1-p6 objects, so



    pe = p1, or later: pe = p4



    for example.



    Is there any way this to be done with PyQtgraph?



    I really tried all kind things in the last two weeks and nothing seems to work.



    I am aware of the



    pe.setXLink(p1)
    pe.setYLink(p2)


    but this only links the axes not the plot object itself. It doesn't work for me.










    share|improve this question



























      0












      0








      0








      I am developing an orbital analysis tool using PyQT5 and pyqtgraph!



      See: https://github.com/3fon3fonov/trifon



      My tool has a plotting area with ~15 plots shown in different tab windows, which show different aspects of the data analysis.



      The tool it self is assembled with the Designer-qt5, while the QGraphicView widgets are promoted to pyqtgraphs's PlotWidgets



      For example in the gui.py I initialize the plots like this:



      def initialize_plots(self):
      global p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,pe
      p1 = self.graphicsView_timeseries_RV
      p2 = self.graphicsView_timeseries_RV_o_c
      p3 = self.graphicsView_timeseries_phot
      p4 = self.graphicsView_timeseries_phot_o_c
      p5 = self.graphicsView_timeseries_activity
      p6 = self.graphicsView_timeseries_correlations
      # ...
      pe = self.graphicsView_extra_plot
      # ...


      so p1-p6 in this case are different PlotWidget objects on which I add Items/Plot data, i.e. p1.plot(x,y), p1.addItem(), etc.



      What I want is to link pe to any of p1-p6!. pe is an extra plot so the user can choose from those already available/created.
      Thus the user can select which plot he/she wants to see next to the main plot.



      Lets imagine that the ComboBox dropdown menu selects between p1-p6 objects, so



      pe = p1, or later: pe = p4



      for example.



      Is there any way this to be done with PyQtgraph?



      I really tried all kind things in the last two weeks and nothing seems to work.



      I am aware of the



      pe.setXLink(p1)
      pe.setYLink(p2)


      but this only links the axes not the plot object itself. It doesn't work for me.










      share|improve this question
















      I am developing an orbital analysis tool using PyQT5 and pyqtgraph!



      See: https://github.com/3fon3fonov/trifon



      My tool has a plotting area with ~15 plots shown in different tab windows, which show different aspects of the data analysis.



      The tool it self is assembled with the Designer-qt5, while the QGraphicView widgets are promoted to pyqtgraphs's PlotWidgets



      For example in the gui.py I initialize the plots like this:



      def initialize_plots(self):
      global p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,pe
      p1 = self.graphicsView_timeseries_RV
      p2 = self.graphicsView_timeseries_RV_o_c
      p3 = self.graphicsView_timeseries_phot
      p4 = self.graphicsView_timeseries_phot_o_c
      p5 = self.graphicsView_timeseries_activity
      p6 = self.graphicsView_timeseries_correlations
      # ...
      pe = self.graphicsView_extra_plot
      # ...


      so p1-p6 in this case are different PlotWidget objects on which I add Items/Plot data, i.e. p1.plot(x,y), p1.addItem(), etc.



      What I want is to link pe to any of p1-p6!. pe is an extra plot so the user can choose from those already available/created.
      Thus the user can select which plot he/she wants to see next to the main plot.



      Lets imagine that the ComboBox dropdown menu selects between p1-p6 objects, so



      pe = p1, or later: pe = p4



      for example.



      Is there any way this to be done with PyQtgraph?



      I really tried all kind things in the last two weeks and nothing seems to work.



      I am aware of the



      pe.setXLink(p1)
      pe.setYLink(p2)


      but this only links the axes not the plot object itself. It doesn't work for me.







      pyqtgraph






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 24 '18 at 21:32









      eyllanesc

      78.7k103256




      78.7k103256










      asked Nov 24 '18 at 16:42









      Trifon TrifonovTrifon Trifonov

      2016




      2016
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I implemented something like that using Docks and a DockArea. I simply added several docks stacked below each other.
          They can be shown using either by clicking on the labels or by using the raiseDock() method of each dock.



          You can simply add the PlotWidget (or any other Widget) to the dock using the addWidget() method of each dock.
          The labels can be hidden or locked if you don't want the user to be able to move the docks at runtime.



          import sys
          import pyqtgraph as pg
          from pyqtgraph.Qt import QtGui
          from pyqtgraph.dockarea import DockArea, Dock

          class Accel_GUI():
          def __init__(self, window, dock_area):
          self.testing = 0
          self.pen = pg.mkPen(color='y')
          """Setup the UI"""
          self.window = window
          self.dock_area = dock_area
          self.window.setCentralWidget(self.dock_area)
          self.spec_dock =
          self.spec_dock.append(Dock("Spectro 1",
          size=(1200, 600),
          autoOrientation=False))
          self.spec_dock.append(Dock("Spectro 2",
          size=(1200, 600),
          autoOrientation=False))
          self.dock_area.addDock(self.spec_dock[0], "top")
          self.dock_area.addDock(self.spec_dock[1], "below", self.spec_dock[0])

          if __name__ == "__main__":
          app = QtGui.QApplication.instance()
          if app is None:
          app = QtGui.QApplication(argv)
          win = QtGui.QMainWindow()
          area = DockArea()
          pyqtplot = Accel_GUI(win, area)
          win.show()
          app.exec_()


          There is also an example in the pyqtgraph library that shows how to work with docks.






          share|improve this answer
























          • Thanks CRose! I will try it out and will report!

            – Trifon Trifonov
            Nov 28 '18 at 8:33











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53460265%2fpyqtgraph-how-to-link-two-plotwidget-windows-to-show-the-same-plot%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          I implemented something like that using Docks and a DockArea. I simply added several docks stacked below each other.
          They can be shown using either by clicking on the labels or by using the raiseDock() method of each dock.



          You can simply add the PlotWidget (or any other Widget) to the dock using the addWidget() method of each dock.
          The labels can be hidden or locked if you don't want the user to be able to move the docks at runtime.



          import sys
          import pyqtgraph as pg
          from pyqtgraph.Qt import QtGui
          from pyqtgraph.dockarea import DockArea, Dock

          class Accel_GUI():
          def __init__(self, window, dock_area):
          self.testing = 0
          self.pen = pg.mkPen(color='y')
          """Setup the UI"""
          self.window = window
          self.dock_area = dock_area
          self.window.setCentralWidget(self.dock_area)
          self.spec_dock =
          self.spec_dock.append(Dock("Spectro 1",
          size=(1200, 600),
          autoOrientation=False))
          self.spec_dock.append(Dock("Spectro 2",
          size=(1200, 600),
          autoOrientation=False))
          self.dock_area.addDock(self.spec_dock[0], "top")
          self.dock_area.addDock(self.spec_dock[1], "below", self.spec_dock[0])

          if __name__ == "__main__":
          app = QtGui.QApplication.instance()
          if app is None:
          app = QtGui.QApplication(argv)
          win = QtGui.QMainWindow()
          area = DockArea()
          pyqtplot = Accel_GUI(win, area)
          win.show()
          app.exec_()


          There is also an example in the pyqtgraph library that shows how to work with docks.






          share|improve this answer
























          • Thanks CRose! I will try it out and will report!

            – Trifon Trifonov
            Nov 28 '18 at 8:33
















          0














          I implemented something like that using Docks and a DockArea. I simply added several docks stacked below each other.
          They can be shown using either by clicking on the labels or by using the raiseDock() method of each dock.



          You can simply add the PlotWidget (or any other Widget) to the dock using the addWidget() method of each dock.
          The labels can be hidden or locked if you don't want the user to be able to move the docks at runtime.



          import sys
          import pyqtgraph as pg
          from pyqtgraph.Qt import QtGui
          from pyqtgraph.dockarea import DockArea, Dock

          class Accel_GUI():
          def __init__(self, window, dock_area):
          self.testing = 0
          self.pen = pg.mkPen(color='y')
          """Setup the UI"""
          self.window = window
          self.dock_area = dock_area
          self.window.setCentralWidget(self.dock_area)
          self.spec_dock =
          self.spec_dock.append(Dock("Spectro 1",
          size=(1200, 600),
          autoOrientation=False))
          self.spec_dock.append(Dock("Spectro 2",
          size=(1200, 600),
          autoOrientation=False))
          self.dock_area.addDock(self.spec_dock[0], "top")
          self.dock_area.addDock(self.spec_dock[1], "below", self.spec_dock[0])

          if __name__ == "__main__":
          app = QtGui.QApplication.instance()
          if app is None:
          app = QtGui.QApplication(argv)
          win = QtGui.QMainWindow()
          area = DockArea()
          pyqtplot = Accel_GUI(win, area)
          win.show()
          app.exec_()


          There is also an example in the pyqtgraph library that shows how to work with docks.






          share|improve this answer
























          • Thanks CRose! I will try it out and will report!

            – Trifon Trifonov
            Nov 28 '18 at 8:33














          0












          0








          0







          I implemented something like that using Docks and a DockArea. I simply added several docks stacked below each other.
          They can be shown using either by clicking on the labels or by using the raiseDock() method of each dock.



          You can simply add the PlotWidget (or any other Widget) to the dock using the addWidget() method of each dock.
          The labels can be hidden or locked if you don't want the user to be able to move the docks at runtime.



          import sys
          import pyqtgraph as pg
          from pyqtgraph.Qt import QtGui
          from pyqtgraph.dockarea import DockArea, Dock

          class Accel_GUI():
          def __init__(self, window, dock_area):
          self.testing = 0
          self.pen = pg.mkPen(color='y')
          """Setup the UI"""
          self.window = window
          self.dock_area = dock_area
          self.window.setCentralWidget(self.dock_area)
          self.spec_dock =
          self.spec_dock.append(Dock("Spectro 1",
          size=(1200, 600),
          autoOrientation=False))
          self.spec_dock.append(Dock("Spectro 2",
          size=(1200, 600),
          autoOrientation=False))
          self.dock_area.addDock(self.spec_dock[0], "top")
          self.dock_area.addDock(self.spec_dock[1], "below", self.spec_dock[0])

          if __name__ == "__main__":
          app = QtGui.QApplication.instance()
          if app is None:
          app = QtGui.QApplication(argv)
          win = QtGui.QMainWindow()
          area = DockArea()
          pyqtplot = Accel_GUI(win, area)
          win.show()
          app.exec_()


          There is also an example in the pyqtgraph library that shows how to work with docks.






          share|improve this answer













          I implemented something like that using Docks and a DockArea. I simply added several docks stacked below each other.
          They can be shown using either by clicking on the labels or by using the raiseDock() method of each dock.



          You can simply add the PlotWidget (or any other Widget) to the dock using the addWidget() method of each dock.
          The labels can be hidden or locked if you don't want the user to be able to move the docks at runtime.



          import sys
          import pyqtgraph as pg
          from pyqtgraph.Qt import QtGui
          from pyqtgraph.dockarea import DockArea, Dock

          class Accel_GUI():
          def __init__(self, window, dock_area):
          self.testing = 0
          self.pen = pg.mkPen(color='y')
          """Setup the UI"""
          self.window = window
          self.dock_area = dock_area
          self.window.setCentralWidget(self.dock_area)
          self.spec_dock =
          self.spec_dock.append(Dock("Spectro 1",
          size=(1200, 600),
          autoOrientation=False))
          self.spec_dock.append(Dock("Spectro 2",
          size=(1200, 600),
          autoOrientation=False))
          self.dock_area.addDock(self.spec_dock[0], "top")
          self.dock_area.addDock(self.spec_dock[1], "below", self.spec_dock[0])

          if __name__ == "__main__":
          app = QtGui.QApplication.instance()
          if app is None:
          app = QtGui.QApplication(argv)
          win = QtGui.QMainWindow()
          area = DockArea()
          pyqtplot = Accel_GUI(win, area)
          win.show()
          app.exec_()


          There is also an example in the pyqtgraph library that shows how to work with docks.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 27 '18 at 14:43









          CRoseCRose

          364




          364













          • Thanks CRose! I will try it out and will report!

            – Trifon Trifonov
            Nov 28 '18 at 8:33



















          • Thanks CRose! I will try it out and will report!

            – Trifon Trifonov
            Nov 28 '18 at 8:33

















          Thanks CRose! I will try it out and will report!

          – Trifon Trifonov
          Nov 28 '18 at 8:33





          Thanks CRose! I will try it out and will report!

          – Trifon Trifonov
          Nov 28 '18 at 8:33




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53460265%2fpyqtgraph-how-to-link-two-plotwidget-windows-to-show-the-same-plot%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          TypeError: fit_transform() missing 1 required positional argument: 'X'