Skip to content
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

Bug Report: Spyder Ipython crashing after mplfinance.plot() #183

Closed
cleitonmoya opened this issue Jun 20, 2020 · 5 comments
Closed

Bug Report: Spyder Ipython crashing after mplfinance.plot() #183

cleitonmoya opened this issue Jun 20, 2020 · 5 comments
Labels
bug Something isn't working released code merged into repo AND released to Pypi

Comments

@cleitonmoya
Copy link

Describe the bug
Running mplfinance.plot() in Spyder, if Ipython Console is set with automatic graphic output (Preference->Ipython Console->Graphics->Output: Automatic), Ipython crashes.
Please verify if this bug is related to mplfinance.

To Reproduce

  1. Set Spyder preferente to plot graphic output not inline (Preference->Ipython Console->Graphics->Output: Automatic);
  2. Run the "Basic Usage" tutorial (https://github.com/matplotlib/mplfinance#usage);
  3. See Ipython console crashing.

Expected behavior
Figure generated without Ipython console crashing.

Desktop (please complete the following information):

  • mplfinance 0.12.5a2
  • Spyder 4.0.1
  • Python 3.7.6 64 bits
  • Qt 5.9.6
  • PyQt5 5.9.2
  • Windows 10.0.18362.900

Additional context
Using inline graphics configuration, Ipyhton do not crash.

@cleitonmoya cleitonmoya added the bug Something isn't working label Jun 20, 2020
@DanielGoldfarb
Copy link
Collaborator

Cleiton,

What do you mean by "crashing"? Since you have not posted a Traceback or similar evidence of a crash, I am going to assume you mean that the Ipython console is unresponsive (not necessarily a crash). If you mean something else, please let me know.

Most likely the Ipython console is unresponsive because matplotlib is waiting for input. The default for matplotlib.pyplot.show(), when displaying the plot in a separate window, is to block further running of the plotting script until the user finishes interacting with with the plot window and closes it. If you close the plot window, then your Ipython console should continue running.

You can disengage this default behavior by including kwarg block=False:

mplfinance.plot(data,...,block=False,...)

Please let me know if that helps. All the best. --Daniel

@cleitonmoya
Copy link
Author

Hi Daniel,

You are right, what I mean is Ipython console gets unresponsive. But this persists even after closing the plot window (Ipython console stucks running). Even the stop button of the console does not work and I need to close the current console and start a new one.

But using the kwarg block=False works! It seems the problem is the close event of the plot window is getting not captured by Ipyhton console. Anyway, using the kwarg doesn't bother me :) Thank you very much for the help.

Kind regards,
Cleiton

@DanielGoldfarb
Copy link
Collaborator

Cleiton,
Thank you for letting me know. I'm glad block=False is working for you. I have heard this before: With simple ipython, closing the plot window will cause the ipython prompt to come back and everything is fine, but apparently the ipython console in Spyder gets stuck. As you said the close event is somehow not captured.

I've never used Spyder. When I have some extra time I will try and see if I can reproduce the problem. At this point its difficult to say if the issue is the way matplotlib implements the block, or how Spyder responds to it.

@DanielGoldfarb
Copy link
Collaborator

DanielGoldfarb commented Jun 22, 2020

I have decided this is indeed a bug. I was under the impression that kwarg block had two possible values, True and False. Apparently it has also a third possible value: None which behaves differently from either True or False.

What None does is behave as if True for regular Python and simple Ipython, but behave as if False for "Ipython with its pylab mode" (which is apparently what Spyder uses).

Therefore I am changing the default value of block to be None. Users can override the default by setting the kwarg to either True or False. I was able to reproduce the issue running Spyder on Ubuntu, and confirmed that changing the default value fixes the issue.

I expect to release this change by the end of this week.

@DanielGoldfarb DanielGoldfarb added in progress released code merged into repo AND released to Pypi and removed in progress labels Jun 22, 2020
@DanielGoldfarb
Copy link
Collaborator

pip install --upgrade mplfinance and you won't need block=False anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released code merged into repo AND released to Pypi
Projects
None yet
Development

No branches or pull requests

2 participants