matplotlib legend multiple columns code example Example: matplotlib legend multiple columns plt.legend(ncol=k)