Pyqt5, Matplotlib incompatibility?
-
wrote on 5 Aug 2020, 10:33 last edited by
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) -
Hi,
Did you try to tell matplotlib to explicitly use its Qt backend ?
-
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)@Samuel-Liu_ said in Pyqt5, Matplotlib incompatibility?:
It does not work if i import QFileDialog
What does "does not work" mean exactly? What happens?
-
wrote on 5 Aug 2020, 11:13 last edited byThis post is deleted!
-
@Samuel-Liu_ said in Pyqt5, Matplotlib incompatibility?:
It does not work if i import QFileDialog
What does "does not work" mean exactly? What happens?
wrote on 5 Aug 2020, 11:27 last edited by@jsulm A Non responsive white box appears and crashes python
-
@jsulm A Non responsive white box appears and crashes python
@Samuel-Liu_ And this does not happen if you remove
from PyQt5.QtWidgets import QFileDialog
?
-
@Samuel-Liu_ And this does not happen if you remove
from PyQt5.QtWidgets import QFileDialog
?
wrote on 5 Aug 2020, 11:39 last edited by@jsulm This does not happen.
I can also only post every 10 minutes because of the reputation restriction here -
@Samuel-Liu_ And this does not happen if you remove
from PyQt5.QtWidgets import QFileDialog
?
wrote on 5 Aug 2020, 12:09 last edited by@jsulm Can you replicate the issue? I want to know if its just me
-
@jsulm Can you replicate the issue? I want to know if its just me
@Samuel-Liu_ Start the script from a terminal and see whether there are any errors/warnings.
-
@Samuel-Liu_ Start the script from a terminal and see whether there are any errors/warnings.
wrote on 5 Aug 2020, 12:31 last edited by@jsulm No errors just an unresponsive white box
-
Hi,
Did you try to tell matplotlib to explicitly use its Qt backend ?
-
wrote on 6 Aug 2020, 11:40 last edited by
@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')
8/11