Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2192

Interactive plots do not work (no PyOS_InputHook)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.8.0, 6.7.3
    • 6.4.2
    • PySide
    • None
    • All
    • 1864c7982 (dev), e2b5c0050 (6.7)

    Description

      I noticed that when using PySide as a backend for Matplotlib, plots do not work in the interactive interpreter (they do not open). This is in contrast to PyQt, where this works. I think the reason is that PySide does not implement the
      PyOS_InputHook API, which allows the event loop to run in the background.

      Here's a minimal example to reproduce the issue (this assumes that both PySide6 and matplotlib packages are installed; it is important that PyQt6 is not installed simultaneously):

      • Start the interactive interpreter: python
      • Run the following commands (line by line):
      import matplotlib
      import matplotlib.pyplot as plt
      
      matplotlib.use("QtAgg")  # will use PySide6
      plt.ion()  # turn on interactive mode
      plt.plot(1)  # should open a figure, but this does not work
      

      Note that in this example, if you install PyQt6 instead of PySide6, everything works (the figure opens as expected).

      Note also that this example does work in IPython, even with PySide, because IPython provides its own input hook.

      Some additional discussion can be found here: https://github.com/matplotlib/matplotlib/issues/15359#issuecomment-1380734369

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kleint Friedemann Kleint
            cle1109 Clemens Brunner
            Votes:
            4 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes