I always use the following pattern:
x_inches = 150*(1/25.4) # [mm]*constant
y_inches = x_inches*(0.8)
dpi = 96
fig = plt.figure(1, figsize = (x_inches,y_inches), dpi = dpi, constrained_layout = True)
With this example you are able to set figure dimensions in inches or in milimiters and setting constrained_layout
to True
plots fill your figure without borders.