How to get matplotlib figure size
import matplotlib.pltfig = plt.figure()size = fig.get_size_inches()*fig.dpi # size in pixels
To do it for the current figure,
fig = plt.gcf()size = fig.get_size_inches()*fig.dpi # size in pixels
You can get the same info by doing:
bbox = fig.get_window_extent().transformed(fig.dpi_scale_trans.inverted())width, height = bbox.width*fig.dpi, bbox.height*fig.dpi
Figure size in inches
To get width and height in inches I just use:
fig_width, fig_height = plt.gcf().get_size_inches()
I thought I'd put it here because this question is the first result that pops up when you search 'get matplotlib figure size', and the api most naturally works in inches, not pixels.