I can create very nice figures with
import matplotlib.pyplot as plt
fig = plt.figure()
often, I need to generate large figures and I do
fig = plt.figure(figsize=(80,60))
which is fine, but generates figures that are larger than the screen and need to be manually resized. This is desired behavior, if I read the documentation I see:
figsize
w,h tuple in inches
So I have found the sizes of my screen manually, and now it generate nice fullscreen figures. However, if I change monitor I need to repat this. How do I find programmtatically the size of the screen in use?
I have found many answers, but they all rely on external libraries or are platform-specific, or back-end specific Any solution that I could trasparently use across OS, backends, without adding dependencies to my project?
How to determine screen size in matplotlib.
I have tried
window = plt.get_current_fig_manager().window
screen_x, screen_y = window.wm_maxsize()
but I am seeing the following exception:
AttributeError: 'MainWindow' object has no attribute 'wm_maxsize'
I am using Python 2.7 within Anaconda on Linux, Win 7+ with a automatic graphic backend.
UPDATE
It seems that many ways exist
https://www.blog.pythonlibrary.org/2015/08/18/getting-your-screen-resolution-with-python/
How do I get monitor resolution in Python?
https://stackoverflow.com/a/42355364/2666859
However, none of them is platform or backend independent. Perhaps an alternative is first detect platform and then the backend in use and cascade in a long multicase if with all the particular solutions as cases? Apparently, such a chain solution exists https://stackoverflow.com/a/21213145/4124317
Is this pythonic?Is the best way to go?