How do I set the matplotlib window size when the window is displayed?
macos, matplotlib, python
Solution
For all backends, the window size is controlled by the `figsize` argument.
For example:
import matplotlib.pyplot as plt
fig, axes = plt.subplots(5, 5, figsize=(12, 10))
plt.show()
If you're creating the figure and subplots separately, you can specify the size to `plt.figure` (This is exactly equivalent to the snippet above):
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(12, 10))
for i in range(1, 26):
fig.add_subplot(5, 5, i)
plt.show()
In general, for any matplotlib figure object, you can also call `fig.set_size_inches((width, height))` to change the size of the figure.
Problem
I have a python plotting function that creates a grid of matplotlib subplots and I want the size of the window the plots are drawn in to depend on the size of the subplot grid. For example, if the subplots grid is 5 rows by 5 columns (25 subplots) the window size needs to be bigger than one where there is only 5 subplots in a single column. I'm not sure how to control the window size matplotlib creates plots in. Can someone tell me how to control the plot window size for matplotlib using the MacOSX backend?