My Python script executes in a new dedicated Python console in Spyder, where I have configured Spyder's run options to allow interaction with the dedicated Python console after execution. After execution, my script leaves multiple figure windows open and minimized. I do the following:
Click on the last figure window to bring it into focus.
Click on the icon "Edit curves line and axis parameters"
Change the X-axis max parameter
Click Apply
Click OK
matplotlib minimizes the window I just edited, then freezes. When I click on another figure window, the figure window I just edited pops up instead. When I try to edit the axis parameter of the same figure again, I hear the Windows error beep sound.
I have observed this problem in:
a) Python 3.5.2, Spyder 3.0.2, matplotlib 1.5.3, Qt 5.7.0, PyQt5 5.7
b) Python 3.5.2, Spyder 3.1.0dev, matplotlib 2.0.0rc2, Qt 5.7.0, PyQt5 5.7
c) Python 3.4.4, Spyder 3.0.2, matplotlib 1.5.3, Qt 5.5.1, PyQtt 5.5.1
The problem is a regression, because my same script works fine in:
d) Python 3.5.2, Spyder 2.3.9, matplotlib 1.5.3, Qt 4.8.7, PyQt4 4.11.4
e) Python 3.5.2, Spyder 3.1.0dev, matplotlib 2.0.0rc2, Qt 4.8.7, PyQt4 4.11.4
No other projects are currently tracking this issue. In the WinPython project, I gave this issue as the reason why I continue to need PyQt4 for now.
I tried to execute in plain python and by configuring Spyder's run settings to execute in an external System terminal. In both cases, tkinter is used as the backend instead of Qt, and only one figure window displays at a time (I have to close one figure window to see the next, and I can't go back). matplotlib's figure edit menu is totally different with tkinter. I don't see the same problem with tkinter, but then tkinter is not usable for me since I can't navigate between multiple figure windows. Qt plots support many more features that I depend on.
How do I get matplotlib to use the Qt backend and support multiple simultaneous figure windows when using plain python? WinPython has a convenient Command Prompt that sets up the PATH environment variable for me. Or is this problem tied to Spyder because it depends on Spyder plot support functions?
You will need to call plt.ion() or make the figures before calling show to not block the command prompt when the figures are up in either plain python or IPython (in the case of IPython you can also use %matplotlib).
I have not yet had time to reproduce the problem outside Spyder or produce a simple example script. Today, however, I reproduced the problem using the latest versions in WinPython 3.5.3.0Qt5:
Could you try in the IPython one, please? I'm sorry to say it but we're about to remove the Python console in the coming months because it has a lot of very, very hard to fix bugs.
I tried the Spyder IPython console. By default, this creates in-line plots within the console. I strongly prefer a separate window for each plot, and the Python console provides this. I need to selectively expand plots to full screen and choose among existing plot windows to view them side-by-side for comparison of processing algorithms. This is just like the visualizations I do in MATLAB.
I found this: http://stackoverflow.com/questions/14261903/how-can-i-open-the-interactive-matplotlib-window-in-ipython-notebook
Using my latest configuration that reproduces the problem (Python 3.5.3, Spyder 3.1.2, matplotlib 2.0.0, Qt 5.7.1, PyQt5 5.7.1), I entered in the IPython console %matplotlib qt. It threw ImportError: No module name 'PyQt4'.
I entered in the IPython console %matplotlib notebook before I ran my Python script, and this correctly produced separate windows for each plot. However, I can't interact with the plots or even view plot figures other than the last one generated. Every time I click on the last figure window, I get a Windows error beep, just like the problem I stated in the opening post.
In my latest working configuration (Python 3.5.3, Spyder 3.1.2, matplotlib 2.0.0, Qt 4.8.7, PyQt4 4.11.4), if I change the Run Settings to "Execute in current Python or IPython console" and then click (move focus) to an IPython console, Spyder crashes.
I resolved this issue by configuring Spyder to run scripts in IPython, and for Spyder's IPython backend to Automatic (instead of Inline). Thanks @ccordoba12 for suggesting IPython!
Activity
tacaswell commented on Dec 26, 2016
Can you reproduce this not in spyder (either in plain python or ipython prompts)? Are there any other tracking issues for this on other projects?
attn @anntzer @ccordoba12
hiccup7 commented on Dec 26, 2016
No other projects are currently tracking this issue. In the WinPython project, I gave this issue as the reason why I continue to need PyQt4 for now.
I tried to execute in plain python and by configuring Spyder's run settings to execute in an external System terminal. In both cases, tkinter is used as the backend instead of Qt, and only one figure window displays at a time (I have to close one figure window to see the next, and I can't go back). matplotlib's figure edit menu is totally different with tkinter. I don't see the same problem with tkinter, but then tkinter is not usable for me since I can't navigate between multiple figure windows. Qt plots support many more features that I depend on.
How do I get matplotlib to use the Qt backend and support multiple simultaneous figure windows when using plain python? WinPython has a convenient Command Prompt that sets up the PATH environment variable for me. Or is this problem tied to Spyder because it depends on Spyder plot support functions?
anntzer commented on Dec 27, 2016
I cannot reproduce the issue with python 3.5.2, matplotlib 1.5.3, pyqt 5.6.0, spyder 3.0.2 (all from conda). The script I tried is
import matplotlib as mpl; mpl.use("qt5agg") from matplotlib import pyplot as plt fig, ax = plt.subplots() mng = plt.get_current_fig_manager() mng.window.showMinimized() fig, ax = plt.subplots() mng = plt.get_current_fig_manager() mng.window.showMinimized() plt.show()tacaswell commented on Dec 27, 2016
@hiccup7 See http://matplotlib.org/faq/usage_faq.html#what-is-a-backend for all of the ways to change the backend.
You will need to call plt.ion() or make the figures before calling show to not block the command prompt when the figures are up in either plain python or IPython (in the case of IPython you can also use %matplotlib).
hiccup7 commented on Feb 5, 2017
I have not yet had time to reproduce the problem outside Spyder or produce a simple example script. Today, however, I reproduced the problem using the latest versions in WinPython 3.5.3.0Qt5:
Again, I worked around the problem by reverting Qt:
ccordoba12 commented on Feb 6, 2017
This seems to be a Windows problem (I can't reproduce it on Linux). I'll take a look at it.
@hiccup7, does this problem appear on Spyder IPython console? Or just the Python one?
hiccup7 commented on Feb 6, 2017
I have not tried the Spyder IPython console. I always use the Spyder Python console.
ccordoba12 commented on Feb 6, 2017
Could you try in the IPython one, please? I'm sorry to say it but we're about to remove the Python console in the coming months because it has a lot of very, very hard to fix bugs.
hiccup7 commented on Feb 6, 2017
I tried the Spyder IPython console. By default, this creates in-line plots within the console. I strongly prefer a separate window for each plot, and the Python console provides this. I need to selectively expand plots to full screen and choose among existing plot windows to view them side-by-side for comparison of processing algorithms. This is just like the visualizations I do in MATLAB.
I found this: http://stackoverflow.com/questions/14261903/how-can-i-open-the-interactive-matplotlib-window-in-ipython-notebook
Using my latest configuration that reproduces the problem (Python 3.5.3, Spyder 3.1.2, matplotlib 2.0.0, Qt 5.7.1, PyQt5 5.7.1), I entered in the IPython console %matplotlib qt. It threw ImportError: No module name 'PyQt4'.
I entered in the IPython console %matplotlib notebook before I ran my Python script, and this correctly produced separate windows for each plot. However, I can't interact with the plots or even view plot figures other than the last one generated. Every time I click on the last figure window, I get a Windows error beep, just like the problem I stated in the opening post.
In my latest working configuration (Python 3.5.3, Spyder 3.1.2, matplotlib 2.0.0, Qt 4.8.7, PyQt4 4.11.4), if I change the Run Settings to "Execute in current Python or IPython console" and then click (move focus) to an IPython console, Spyder crashes.
hiccup7 commented on Apr 16, 2017
I resolved this issue by configuring Spyder to run scripts in IPython, and for Spyder's IPython backend to Automatic (instead of Inline). Thanks @ccordoba12 for suggesting IPython!