def do_plot(ax):
    ax.plot([1, 2, 3], [4, 5, 6], 'k.')
N = 11
cols = 3
rows = int(math.ceil(N / cols))
gs = gridspec.GridSpec(rows, cols)
fig = plt.figure()
for n in range(N):
    ax = fig.add_subplot(gs[n])
do_plot(ax)
fig.tight_layout()
Dynamically add subplots in matplotlib with more than one column