How do you change the size of figure drawn with matplotlib?
You can simply use (from matplotlib.figure.Figure):
fig.set_size_inches(width,height)
As of Matplotlib 2.0.0, changes to your canvas will be visible immediately, as the forward
keyword defaults to True.
If you want to just change the width or height instead of both, you can use
fig.set_figwidth(val)
or fig.set_figheight(val)
These will also immediately update your canvas, but only in Matplotlib 2.2.0 and newer.
You need to specify forward=True
explicitly in order to live-update your canvas in versions older than what is specified above. Note that the set_figwidth
and set_figheight
functions don’t support the forward
parameter in versions older than Matplotlib 1.5.0.