I have a figure with a fixed size and want to change the size of the plot inside it, i.e., add white space around it. Most questions online deal with removing white space or subplots, which I don’t have.
My plotting code is
fig = plt.figure(figsize=(14,10))
plt.plot(n, y)
plt.savefig('figure.png', bbox_inches='tight', dpi=200)
so really nothing special. I already tried margins and tight_layout(pad = X) but nothing worked.
>Solution :
You can adjust the subplot parameters using subplots_adjust
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(14, 10))
plt.plot(n, y)
#Adjust the subplot parameters to add white space
plt.subplots_adjust(left=0.1, right=0.9, top=0.9, bottom=0.1)
plt.savefig('figure.png', dpi=200)
by adjusting the values for left, right, top, and bottom, you can control the amount of white space added around the plot.