I've redacted information where necessary. But this question captures my problem:
Problem Statement:
My objective is simple: given graph data, graph it, and save it as a FULLSCREEN IMAGE automatically. (this needs to scale to a large number of graphs). I looked at: Saving Matplotlib graphs to image as full screen
And came up with the following solution:
import matplotlib.pyplot as plt
#Prepare Data
some_x_array = [0, 1, 2]
other_x_array = [0, 1, 2]
some_y_array = [4, 5, 6]
other_y_array = [7, 8, 9]
#Plot Data
plt.plot(some_x_array, some_y_array)
plt.plot(other_x_array, other_y_array)
plt.legend(['The X Axis', 'The Y Axis'])
#Maximize the Window
manager = plt.get_current_fig_manager()
manager.window.showMaximized()
#Acquire figure before the Image Loads
fig = plt.gcf()
#Show the Image (but don't block the flow)
plt.show(block=False)
#Save the image
fig.savefig('stackoverflowimage.png')
However anyone running this script will realize that the image it produces is not full-size. If you change the line plt.show(block=False)
to plt.show(block=True)
, a graph appears, and once you close it, you will find a full size image.
I want to get a full size image, WITHOUT the graph appearing and demanding human interaction. What to do?
My Attempt at Solving the Problem:
It seems to me the command to make the screen full-size is executed lazily, i.e. I do already maximize the window in the code very early on, but until I show the thing, it never happens.
One Idea then is to try to do a show with a timer (ex: 0.001 seconds) but that feels like a very poor design choice.