Figure size doesn't change the size of my figure

Why isn’t my figure size changing? My subplots are squashed and can’t seem to edit the size. I tried both set_inch_size and figsize = (x, y)

This is part of the recent_grads project.

fig = plt.figure()
fig.set_size_inches(5,5)
fig, ax = plt.subplots()

ax1 = fig.add_subplot(5,1,1)
ax2 = fig.add_subplot(5,1,2)
ax3 = fig.add_subplot(5,1,3)
ax4 = fig.add_subplot(5,1,4)
ax5 = fig.add_subplot(5,1,5)

ax1.scatter(recent_grads['Sample_size'],recent_grads['Median'])
ax2.scatter(recent_grads['Sample_size'],recent_grads['Median'])
plt.show()

Hi @steven.nagliati

You should add the code for changing figure size after adding all the subplots. Also, the first line of your code can be removed and fig identified together with the ax object:

fig, ax = plt.subplots()

ax1 = fig.add_subplot(5,1,1)
ax2 = fig.add_subplot(5,1,2)
ax3 = fig.add_subplot(5,1,3)
ax4 = fig.add_subplot(5,1,4)
ax5 = fig.add_subplot(5,1,5)

fig.set_size_inches(5,5)

ax1.scatter(recent_grads['Sample_size'],recent_grads['Median'])
ax2.scatter(recent_grads['Sample_size'],recent_grads['Median'])
plt.show()
1 Like