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

Created on 20 Jun 2020  路  5Comments  路  Source: matplotlib/mplfinance

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.

bug released

All 5 comments

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

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

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.

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 that 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.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Full4me picture Full4me  路  3Comments

viorell91 picture viorell91  路  3Comments

schorschie picture schorschie  路  3Comments

allahyarzadeh picture allahyarzadeh  路  3Comments

tmcguire65 picture tmcguire65  路  6Comments