grouped = df.groupby('a')
rowlength = grouped.ngroups / 2
fig, axs = plt.subplots(figsize=(9, 4), nrows=2, ncols=rowlength,
    gridspec_kw=dict(hspace=0.4))
targets = zip(list(grouped.groups.keys()), axs.flatten())
for i, (key, ax) in enumerate(targets):
    ax.plot(grouped.get_group(key))
ax.set_title('a=%d' % key)
ax.legend()
plt.show()
How to create Pandas groupby plot with subplots?