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.6k 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_
    5 Aug 2020, 10:33

    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)

    J Offline
    J Offline
    jsulm
    Lifetime Qt Champion
    wrote on 5 Aug 2020, 10:59 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 5 Aug 2020, 11:27
    0
    • S Offline
      S Offline
      Samuel.Liu_
      wrote on 5 Aug 2020, 11:13 last edited by
      #3
      This post is deleted!
      1 Reply Last reply
      0
      • J jsulm
        5 Aug 2020, 10:59

        @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 5 Aug 2020, 11:27 last edited by
        #4

        @jsulm A Non responsive white box appears and crashes python

        J 1 Reply Last reply 5 Aug 2020, 11:28
        0
        • S Samuel.Liu_
          5 Aug 2020, 11:27

          @jsulm A Non responsive white box appears and crashes python

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 5 Aug 2020, 11:28 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 5 Aug 2020, 11:39
          0
          • J jsulm
            5 Aug 2020, 11:28

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

            from PyQt5.QtWidgets import QFileDialog
            

            ?

            S Offline
            S Offline
            Samuel.Liu_
            wrote on 5 Aug 2020, 11:39 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
            • J jsulm
              5 Aug 2020, 11:28

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

              from PyQt5.QtWidgets import QFileDialog
              

              ?

              S Offline
              S Offline
              Samuel.Liu_
              wrote on 5 Aug 2020, 12:09 last edited by
              #7

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

              J 1 Reply Last reply 5 Aug 2020, 12:24
              0
              • S Samuel.Liu_
                5 Aug 2020, 12:09

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

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 5 Aug 2020, 12:24 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 5 Aug 2020, 12:31
                0
                • J jsulm
                  5 Aug 2020, 12:24

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

                  S Offline
                  S Offline
                  Samuel.Liu_
                  wrote on 5 Aug 2020, 12:31 last edited by
                  #9

                  @jsulm No errors just an unresponsive white box

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 5 Aug 2020, 18:46 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 6 Aug 2020, 11:40
                    1
                    • S SGaist
                      5 Aug 2020, 18:46

                      Hi,

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

                      S Offline
                      S Offline
                      Samuel.Liu_
                      wrote on 6 Aug 2020, 11:40 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

                      11/11

                      6 Aug 2020, 11:40

                      • Login

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