Automatic adjustment of a subplot Python
Question:
Answers:
You have to use plt.tight_layout
:
fig, (ax1, ax2) = plt.subplots(nrows=2, ncols=1)
ax1.plot(arr.real)
ax1.set_title('Real part at the output of the filter')
ax2.plot(arr.imag)
ax2.set_title('Imaginary part at the output of the filter')
plt.tight_layout()
plt.show()
With plt.tight_layout
:
Without plt.tight_layout
:
You have to use plt.tight_layout
:
fig, (ax1, ax2) = plt.subplots(nrows=2, ncols=1)
ax1.plot(arr.real)
ax1.set_title('Real part at the output of the filter')
ax2.plot(arr.imag)
ax2.set_title('Imaginary part at the output of the filter')
plt.tight_layout()
plt.show()
With plt.tight_layout
:
Without plt.tight_layout
: