To improve subplot size/spacing with many subplots in Python matplotlib, we can use the subplots_adjust
method.
For instance, we write
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as tic
fig = plt.figure()
x = np.arange(100)
y = 3.*np.sin(x*2.*np.pi/100.)
for i in range(5):
temp = 510 + i
ax = plt.subplot(temp)
plt.plot(x,y)
plt.subplots_adjust(hspace = .001)
temp = tic.MaxNLocator(3)
ax.yaxis.set_major_locator(temp)
ax.set_xticklabels(())
ax.title.set_visible(False)
plt.show()
to call plt.subplots_adjust
with the hspace
argument to adjust the horizontal spacing.