You can simply use (from matplotlib.figure.Figurefrom matplotlib.figure.Figure):
fig.set_size_inches(width,height)
As of Matplotlib 2.0.0 it will even automatically update, changes to your canvas will be visible immediately, as the forward keyword now defaults to True. (For earlier versions you need to specify forward=True explicitlydefaults to True.)
If you want to just change the width or heightchange the width or height instead of both, you can use
fig.set_figwidth(val)
fig.set_figwidth(val) or fig.set_figheight(val)
fig.set_figheight(val)
These will also immediately update your canvas, but only in Matplotlib 2.2.0 and newer.
For Older Versions
Unfortunately youYou need to specify forward=True explicitly in order to automatically propagatelive-update your canvas in versions older than what is specified above. Note that the changes as it still defaults to Falseset_figwidth for these functions, though this is being fixed.and (Theseset_figheight functions don’t support the forward parameter in versions older than Matplotlib 1.5.0).