New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to see plots made with Matplotlib while debugging #620
Comments
From al.dan...@gmail.com on 2011-04-12T15:40:57Z Forgot to add that this is with spyder 2.0.8 and ipython 0.10.1. |
From ccordoba12 on 2011-05-15T19:31:44Z Labels: Cat-Debugger |
From ccordoba12 on 2011-08-16T11:41:02Z issue #733 has been merged into this issue. |
From eigenjoh...@gmail.com on 2011-11-10T07:23:21Z this fix would make this application a matlab killer |
From kavaldj...@gmail.com on 2013-05-12T21:43:03Z Has this been fixed or addressed somehow? I agree with comment |
From contrebasse on 2013-05-13T00:37:52Z #1: this is normal, the defalut backend for matplotlib is WXAgg. You can change it in your script : import matplotlib |
From jed.lud...@gmail.com on 2013-05-13T07:45:45Z Additional recent diagnostics after doing a bit more testing:
Soyder 2.3.0dev ( revision 0bb65fdb4b6e ) |
From kavaldj...@gmail.com on 2013-05-14T13:45:31Z #8 Jed, thanks!! Running debug in a dedicated interpreter works for me, thanks for the great hint! I apologize if I appear greedy, but is there a simple way to make the figure non-modal? Right now it blocks the interpreter as it is stopped in Pdb, may be there is another trick I can use? I am just calling imshow(data), show(). Thank you so much in advance! |
From jed.lud...@gmail.com on 2013-05-14T16:55:16Z @-kavaldijiev: Making the figure non-modal is the difficult piece to solve. It looks like Carlos looked into solving this under issue #733 , and it may not be straightforward without some interesting thread work. It probably has something to do with matplotlib's interactive mode having to run in parallel with pdb, and you'd have to figure out how to get those threads to cooperate. Note that if you are trying to plot during debugging in the IPython Qt Console, it blocks, too, after you issue the "show()" command. It's not completely interactive there, either. Running in a dedicated interpreter looks like the best workaround for now. |
From kavaldj...@gmail.com on 2013-05-15T14:54:57Z @-jed Thank you for the detailed explanation! I will manage with modal figures. But it is definitely worth making it work in the long run, it could be extremely attractive to the MATLAB crowd. |
From jed.lud...@gmail.com on 2013-05-16T07:57:29Z @-kavaldijiev: After a little more investigation, there is another workaround that should provide you a way to interactively plot while debugging. It seems that it's probably the Qt GUI components that are getting in the way of interactive plotting. If you run IPython without the Qt console interface, interactive plotting works while debugging without blocking. Here are the commands:
|
From jed.lud...@gmail.com on 2013-05-16T15:11:32Z And, after a bit more research, I found this answer: http://stackoverflow.com/questions/12822762/pylab-ion-in-python-2-matplotlib-1-1-1-and-updating-of-the-plot-while-the-pro/12826273#12826273 So, if the code in the original post is modified in this manner: from matplotlib.pyplot import imshow, pause you can get the plot to update, interactively, inside of a Spyder interactive console during debugging without blocking! So, use pause(1) instead of show(). The plot only becomes interactive for the pause duration, so if you want more time to zoom or pan in the data, use pause(10) or pause(20). Works in the IPython Qt Console, too. |
From kavaldj...@gmail.com on 2013-05-16T22:35:04Z @-jed, thanks, both methods work! The command prompt method appears more robust -- I can close the opened figures, and the figures can get the focus (for zoom, etc) until closed. The pause method is obviously preferable since it's within Spyder. The pause returns the keyboard control, but the window shouldn't be closed, otherwise the interpreter hangs in. Opening more new figures is shaky -- sometimes succeeds, other times does not, but I did not spend much time testing. In any case, any of those are extremely useful for debugging, even not as easy and robust as ML. Cheers, |
From al.dan...@gmail.com on 2013-05-19T21:08:30Z Glad to see progress after a couple of years. Yes, the pause(n) trick works well for me. Thanks, @-jed, for following through with a solution! |
From jed.lud...@gmail.com on 2013-05-20T09:13:28Z I can't take much credit for anything other than investigation. The pause(n) function is a matplotlib feature I just happened to discover. Ultimately, the root of this problem is really the interplay between matplotlib drawing event loops and Qt application event loops, and I'm not sure there is really a "Spyder" solution to it. It probably has to be addressed at the matplotlib level. As eveidence of this, IPython running in Qt consoles suffers these same limitations. |
From jason.bo...@gmail.com on 2014-07-07T05:33:04Z This issue seems to have been solved in IEP: https://bitbucket.org/iep-project/iep/issue/297/interactive-plotting-is-not-working-during |
From ccordoba12 on 2014-07-07T07:53:08Z issue #1848 has been merged into this issue. |
I was just wondering if someone could give me a little perspective on where we are headed with all this. I suspect that I'm not the only one out there who has spent a lot of time using Matlab and is very attracted to the Python world for various reasons and senses that true productivity is tantalyzingly close but like a mirage seems to be always just out of reach. The pause() workaround is great and the responsiveness of the Spyder team is truly impressive. And now that the slow editor problem in El Capitan is seemingly slayed in 3.0 beta, it all seems so close. And yet ... So where does an expert think this is all headed? From what I can gather, a big part of the problem is Matplotlib itself. And I also gather that guiqwt isn't is great shape right now either. So do folks think that we are headed towards a situation where we can debug in an IDE, hit breakpoints, and do interactive plotting from the breakpoints, all somewhat seamlessly? I think that is what all ex Matlab users want, and some of us are wondering whether we should pony up the $200 for Matlab Home Edition, going back to The Borg and walking away from the Python approach and the appeal of community based software and the Python language. It may sound like I'm complaining, but I'm actually just trying to figure out how to invest my time. I really want the Python way to be the Matlab killer it could be ... |
@jandyman, please don't despair :-) We've been doing a massive reorganization/cleanup for Spyder 3.0 that would be very beneficial for Spyder 4.0, where we plan to solve this issue. The real problem is not with Matplotlib, it's with the IPython/Jupyter architecture that blocks the console while on debugging, preventing us to run a more featured debugging session (with history browsing and plots) as in Matlab. But let me assure you that after 3.0 is released (in a month or so), all our efforts will be directed to solve the many outstanding and very obnoxious debugging issues Spyder has. If everything goes well and we succeed, we plan to release our fixes in 4.0 (as I said) by the end of the year, or early in the next one :-) |
That's a @PierreRaybaut project (the same one who created Spyder). Unfortunately he doesn't have much time for open source lately :-( |
@ccordoba12, @jandyman: That's right, unfortunately. Regarding @jandyman original post, I can't think that there is no solution out there to use Python/Spyder as a good replacement for MATLAB. Personnally, in 2009, I was already able to do so and without any compromise. But, the solution to implement this in 2009 does not apply anymore to the current state of the code: at that time, Spyder was relying on a "pure" Python interpreter. As @ccordoba12 mentioned, Spyder is now relying on IPython/Jupyter: this is a great thing as it enabled a lot of new features but it also has its drawbacks. |
Any solution for this? I can't close the figure after plt.pause(1). I tried plt.close() and pause again but n success. Thanks |
You have to give the figure number as an argument to |
It didn't work. I run plt.figure(1); plt.imshow(myimage);plt.pause(1);plt.close(1) and no results. I am on IPython 7.11.1, Spyder 4.0.1 and python 3.7.5 |
I was able to reproduce. Please open a new issue about that. As a workaround you can close them with the cross while under |
This workaround worked. Thats weird. Thanks anyway |
This is not just an issue while debugging. I have the inline backend activated. Here's a minimal working example:
If I "Run file" on the example, an inline plot appears. If I select the entirety of the example and "Run selection or current line", an inline plot appears. If I select lines 1-6 and "Run selection or current line", and type the rest of the example in the console, no plot appears. The reference to the plot object does appear. |
I don't think this is related to this bug. This is one limitation of using the inline back-end that the plot doesn't "redraw" itself. If you need to explicitly plot something in the inline back-end, you can do:
|
|
@kdpenner - you'll get the same behavior for example in notebook if you split the code between cells, this is expected. But I don't think you need to use |
|
@kdpenner What I meant was that you'll get the same behavior in other environments with inline backend so this is not an issue with Spyder. |
@mmagnuski Understood. Thanks for the |
🎉 |
Thanks a lot for fixing this! |
exciting! |
You can read about this and the other improvements to our debugger that landed in version 4.2.0 here. |
From al.dan...@gmail.com on 2011-04-12T17:33:50Z
This script, when run within spyder, works fine and produces a contour plot:
#!/usr/bin/env python
from matplotlib.pyplot import imshow, show
import numpy as np
x = np.random.rand(4,5)
imshow(x)
show()
However, if I enter debug mode and put a breakpoint at the imshow(x) line then manually type the imshow(x) and show() commands at the (Pdb) prompt, no plot appears. I only get a reference to the plot object:
(Pdb) imshow(x)
<matplotlib.image.AxesImage object at 0x183f5150>
(Pdb) show()
(Pdb)
Would be a nice enhancement to be able to plot variables in debug mode.
Python 2.7.1
NumPy 1.5.1
matplotlib 1.0.1 (WXAgg backend)
RHEL 4.8 x86_64
Original issue: http://code.google.com/p/spyderlib/issues/detail?id=620
The text was updated successfully, but these errors were encountered: