Skip to content

my code cannot stop #151

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

Closed
scq-wdx opened this issue Jun 7, 2020 · 12 comments
Closed

my code cannot stop #151

scq-wdx opened this issue Jun 7, 2020 · 12 comments
Assignees
Labels
bug Something isn't working question Further information is requested released code merged into repo AND released to Pypi

Comments

@scq-wdx
Copy link

scq-wdx commented Jun 7, 2020

When l use mpf.plot() to plot my picture, my code is continues running, without an In[1] into In[2] in the console.

import pandas as pd
import mplfinance as mpf

df_csv=pd.read_csv("wanke reverse.csv",index_col=0,parse_dates=True)
df_csv.index.name="Date"
df_csv.rename(columns=
    {"open":"Open","high":"High","low":"Low","close":"Close","volume":"Volume"},
    inplace=True)

mpf.plot(df_csv,type="candle",mav=8,volume=True)
@scq-wdx scq-wdx added the question Further information is requested label Jun 7, 2020
@DanielGoldfarb
Copy link
Collaborator

DanielGoldfarb commented Jun 7, 2020

I don't know what you mean by

"my code is continues running, without an In[1] into In[2] in the console."

Can you provide a screen shot, and describe what you expect, and describe what you are seeing that is different from what you expect?

@AndySum
Copy link
Contributor

AndySum commented Jun 8, 2020

How long did you leave it running for? Have you tried plotting with a smaller amount of data?

@moonmoondog
Copy link

Same issue happens to me when I select %matplotlib auto for interactive chart. My IDE is Spyder.

@DanielGoldfarb
Copy link
Collaborator

@scq-wdx @moonmoondog

There is nothing we can do with such a vague description of your issue. Please provide more exact details as requested above. Explain exactly how we can reproduce your issue. Full environment details, including where and how you are running your code. What you expect to see, and what you are seeing. Screen shots may be helpful.

This sounds very much like an environment issue (not matplotlib nor mplfinance related). None-the-less we are happy to help if you can provide some specifics.

@moonmoondog
Copy link

@scq-wdx @moonmoondog

There is nothing we can do with such a vague description of your issue. Please provide more exact details as requested above. Explain exactly how we can reproduce your issue. Full environment details, including where and how you are running your code. What you expect to see, and what you are seeing. Screen shots may be helpful.

This sounds very much like an environment issue (not matplotlib nor mplfinance related). None-the-less we are happy to help if you can provide some specifics.

Thank you for the reply.
I am using Spyder 4.0.1 with Python 3.7.6, Qt5.12.7, PyQt5 5.12.3.
mplfinance version 0.12.5a2
matplotlib version 3.2.0
My code is just simply

import mplfinance as mpf
mpf.plot(OHLC) 

(where OHLC is a pandas dataframe object with open, high, low, close, volume columns)
When I tried to plot the mpf graph inline with the code above, there is no issues at all.
But when I put in a magic command in the iPython platform
%matplotlib auto
or
%matplotlib qt5
for a pop-up interactive graph, a graph window popped up as expected. However the command line does not stop nor terminate by itself just like how the OP descibed. Tried CTRL-C and CTRL-Pause to get out of the process, but to no avial. I had to restart the entire console to make command input works again.
PS: I have been using the vanila matplotlib with no problems. This problem seems to be only assoiciated with mplfinance.

Thank you for this wonderful tool BTW :)

@DanielGoldfarb
Copy link
Collaborator

@moonmoondog

try block=False:

mpf.plot(OHLC,block=False)

Let me know if that works.

@moonmoondog
Copy link

@moonmoondog

try block=False:

mpf.plot(OHLC,block=False)

Let me know if that works.

Thank you for the prompt reply!
I have tried to add the parameter block = False as suggested.
It solved the command line frozen problem. However, the pop-up graph failed to populate and seemed to enter some kind of loop like this:
error
When I tried to force closing the window, the whole iPython kernel failed.
Once again, it works fine with the inline option. It just acts weird when pop-up option is selected.
I have also tried to run the pop-up graph in another thread. However, it freezes the command input as well when the thread re-joins the main.

@AminSaqi
Copy link

block=False

@moonmoondog

try block=False:

mpf.plot(OHLC,block=False)

Let me know if that works.

Fixed my issue.

@moonmoondog
Copy link

@moonmoondog

try block=False:

mpf.plot(OHLC,block=False)

Let me know if that works.

Just a bit of update. I can finally get it works with iPython version updated. Works fine with iPython 7.15.0 now. Thanks for the responses.

@DanielGoldfarb
Copy link
Collaborator

Great news @moonmoondog . Thanks for the update.

@DanielGoldfarb
Copy link
Collaborator

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.

@DanielGoldfarb DanielGoldfarb added bug Something isn't working in progress labels Jun 22, 2020
@DanielGoldfarb DanielGoldfarb self-assigned this Jun 22, 2020
@DanielGoldfarb DanielGoldfarb added released code merged into repo AND released to Pypi and removed in progress labels Jun 24, 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 question Further information is requested released code merged into repo AND released to Pypi
Projects
None yet
Development

No branches or pull requests

5 participants