def flip(items, ncol):
    return itertools.chain(*[items[i::ncol] for i in range(ncol)])
x = np.arange(-2 * np.pi, 2 * np.pi, 0.1)
ax = plt.subplot(111)
ax.plot(x, np.sin(x), label='Sine')
ax.plot(x, np.cos(x), label='Cosine')
ax.plot(x, np.arctan(x), label='Inverse tan')
handles, labels = ax.get_legend_handles_labels()
plt.legend(flip(handles, 2), flip(labels, 2), loc=9, ncol=2)
plt.grid('on')
plt.show()
Matplotlib legend, add items across columns instead of down