Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Pyqt5, Matplotlib incompatibility?
Forum Updated to NodeBB v4.3 + New Features

Pyqt5, Matplotlib incompatibility?

Scheduled Pinned Locked Moved Solved Qt for Python
11 Posts 3 Posters 1.3k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Samuel.Liu_

    Im trying to display a graph with data generated from a Gui using matplotlib.
    It does not work if i import QFileDialog and try to do plt.show(block=False)

    Ive done fresh pip installs of both pyqt5 and matplotlib and here is some code to reproduce:

    import matplotlib.pyplot as plt

    from PyQt5.QtWidgets import QFileDialog

    a=[1,2,3]
    plt.plot(a)
    plt.show(block=False)

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #2

    @Samuel-Liu_ said in Pyqt5, Matplotlib incompatibility?:

    It does not work if i import QFileDialog

    What does "does not work" mean exactly? What happens?

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    S 1 Reply Last reply
    0
    • S Offline
      S Offline
      Samuel.Liu_
      wrote on last edited by
      #3
      This post is deleted!
      1 Reply Last reply
      0
      • jsulmJ jsulm

        @Samuel-Liu_ said in Pyqt5, Matplotlib incompatibility?:

        It does not work if i import QFileDialog

        What does "does not work" mean exactly? What happens?

        S Offline
        S Offline
        Samuel.Liu_
        wrote on last edited by
        #4

        @jsulm A Non responsive white box appears and crashes python

        jsulmJ 1 Reply Last reply
        0
        • S Samuel.Liu_

          @jsulm A Non responsive white box appears and crashes python

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #5

          @Samuel-Liu_ And this does not happen if you remove

          from PyQt5.QtWidgets import QFileDialog
          

          ?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 2 Replies Last reply
          0
          • jsulmJ jsulm

            @Samuel-Liu_ And this does not happen if you remove

            from PyQt5.QtWidgets import QFileDialog
            

            ?

            S Offline
            S Offline
            Samuel.Liu_
            wrote on last edited by
            #6

            @jsulm This does not happen.
            I can also only post every 10 minutes because of the reputation restriction here

            1 Reply Last reply
            0
            • jsulmJ jsulm

              @Samuel-Liu_ And this does not happen if you remove

              from PyQt5.QtWidgets import QFileDialog
              

              ?

              S Offline
              S Offline
              Samuel.Liu_
              wrote on last edited by
              #7

              @jsulm Can you replicate the issue? I want to know if its just me

              jsulmJ 1 Reply Last reply
              0
              • S Samuel.Liu_

                @jsulm Can you replicate the issue? I want to know if its just me

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @Samuel-Liu_ Start the script from a terminal and see whether there are any errors/warnings.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                S 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @Samuel-Liu_ Start the script from a terminal and see whether there are any errors/warnings.

                  S Offline
                  S Offline
                  Samuel.Liu_
                  wrote on last edited by
                  #9

                  @jsulm No errors just an unresponsive white box

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    Hi,

                    Did you try to tell matplotlib to explicitly use its Qt backend ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    S 1 Reply Last reply
                    1
                    • SGaistS SGaist

                      Hi,

                      Did you try to tell matplotlib to explicitly use its Qt backend ?

                      S Offline
                      S Offline
                      Samuel.Liu_
                      wrote on last edited by
                      #11

                      @SGaist No I did not, much thanks for the idea.

                      It works perfectly now. To use matplotlib's Qt backend use the following:

                      import matplotlib
                      matplotlib.use('Qt5Agg')

                      1 Reply Last reply
                      2

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved