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

Automatically make plot fullscreen #85

Open
abdurrahmaan opened this issue Apr 8, 2020 · 7 comments
Open

Automatically make plot fullscreen #85

abdurrahmaan opened this issue Apr 8, 2020 · 7 comments
Labels
question Further information is requested

Comments

@abdurrahmaan
Copy link

Hi,

I'm very new to mplfinance and an amateur with Python

This package is awesome, thank you for your work. I was just wondering if there is a way to make the plot automatically appear in fullscreen? Currently it appears as a window and you have to enlarge it manually...

I know that in Matplotlib it can be done using:
plt.get_current_fig_manager().window.state('zoomed')

Is there a way to do it with mplfinance?

Thank you

@abdurrahmaan abdurrahmaan added the question Further information is requested label Apr 8, 2020
@DanielGoldfarb
Copy link
Collaborator

Not yet. But we could easily add a kwarg to do that. Do you want to write the code for it?

@abdurrahmaan
Copy link
Author

I've never done anything like that before but I'd love to have a go at it. Can you provide me with some guidance please?

@DanielGoldfarb
Copy link
Collaborator

Certain I can guide you. Will have to wait till next week though.

@tradingfran
Copy link

Is there a way to fullscreen?

@DanielGoldfarb
Copy link
Collaborator

This should be relatively easy to code, but according to this answer the code may have to check which backend the user is running.

I tested with backend Qt5Agg and plt.get_current_fig_manager().window.showMaximized() worked fine. Let me know if you are interested in writing the code for mplfinance to support kwarg fullscreen=True.


Alternatively, you can do this now with the following workaround: Set returnfig=True when calling mpf.plot()

Then add the appropriate lines of code from this answer, and call plt.show(), for example:

import mplfinance as mpf
import matplotlib.pyplot as plt

...

mpf.plot(df,...,returnfig=True)
fm = plt.get_current_fig_manager()
fm.window.showMaximized()
plt.show()

@tradingfran
Copy link

It would be great to be able to fullscreen by just setting an atribute = True.

Thank you!

@DanielGoldfarb
Copy link
Collaborator

DId some playing around in plotting.py but could not quite get this to work in all cases:

 783     elif not config['returnfig']:
 784         if config['fullscreen']:
 785             figmgr = plt.get_current_fig_manager()
 786             bkend = plt.get_backend()
 787             if bkend == 'TkAgg':
 788                 #figmgr.window.state('zoomed')
 789                 figmgr.resize(*figmgr.window.maxsize())
 790             elif bkend == 'wxAgg':
 791                 figmgr.frame.Maximize(True)
 792             else: # Qt4Agg, Qt5Agg, maybe others??
 793                 figmgr.window.showMaximized()
 794         plt.show(block=config['block']) # https://stackoverflow.com/a/13361748/1639359
 795         if config['closefig'] == True or (config['block'] and config['closefig']):
 796             plt.close(fig)

not sure whether i want to put code in mplfinance that will strongly depend on the users choice for matplotlib backend, and not be certain that I have all backends working in all operating systems (for example, supposedly figmgr.window.state('zoomed') works on windows but have to use figmgr.resize(*figmgr.window.maxsize()) on ubuntu).

Will leave this issue open for now to see if we can come up with a clean way to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants