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: Unresolved
    • Not Evaluated
    • None
    • 6.4.2
    • PySide
    • None
    • All

    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

        For Gerrit Dashboard: PYSIDE-2192
        # Subject Branch Project Status CR V

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            cle1109 Clemens Brunner
            Votes:
            4 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There is 1 open Gerrit change