How to make matplotlib figure occupy whole Canvas Area?

If you want the matplotlib figures to take the whole canvas area, you need to add tight_layout and use a negative pad value – See below for an example. In this example, I was using a 3d projection for the figure.

fig = plt.figure(figsize=(16, 9))
ax = fig.gca(projection="3d", proj_type="ortho")
plt.plot(x, y, z)

# Fills up the canvas more and more
plt.tight_layout(pad=-5.2)
Before and after adding the tight_layout() and the pad value

Leave a comment