Skip to content

How can I continue the script after mplfinance.plot()? #20

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
schorschie opened this issue Jan 28, 2020 · 4 comments
Closed

How can I continue the script after mplfinance.plot()? #20

schorschie opened this issue Jan 28, 2020 · 4 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@schorschie
Copy link

When calling mpl.plot() in a script the program stops, until the figure is closed. How can I open figures in background? I tried plt.ioff() but it didn't work.

@schorschie schorschie added the question Further information is requested label Jan 28, 2020
@DanielGoldfarb
Copy link
Collaborator

Someone else brought up this same issue in an email a couple of days ago. I will investigate when I have time (hopefully in a week or two).

I'm not sure, but my current hypothesis is that it has something to do with the fact that mpf.plot() is calling plt.show(), in which case adding a noshow=True kwarg, or the proposed mpf.axplot() API, may fix the problem.

@DanielGoldfarb
Copy link
Collaborator

This appears to be the solution. I will test it next week, and if it works will implement something similar.

(If I understand that answer correctly, it means the caller/user of mplfinance will be responsible to call plt.show() if they want the plot window to remain open after their script exits.)

@DanielGoldfarb
Copy link
Collaborator

DanielGoldfarb commented Jan 29, 2020

The next release, mpf.plot() will accept the kwarg block=False (default value is True) to continue the script. You must however allow blocking on the last call to mpf.plot(), or otherwise somehow prevent your script from exiting. (If you do not allow blocking, and do not prevent the script from exiting, then when the script exits all non-blocked plot windows will close.) This solution was based on this answer.

@DanielGoldfarb DanielGoldfarb added the enhancement New feature or request label Jan 29, 2020
@DanielGoldfarb
Copy link
Collaborator

This is now released. pip install --upgrade mplfinance to pick up the enhancement.
mpf.plot(data,block=False) to not block.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants