if sort_legend:
    patches, labels, dummy = zip(*sorted(zip(patches, labels, y), key=lambda
        x: x[2], reverse=True))
plt.legend(patches, labels, loc='left center', bbox_to_anchor=(-0.1, 1.0),
    fontsize=8)
plt.savefig('piechart.png', bbox_inches='tight')
How to avoid overlapping of labels & autopct in a matplotlib pie chart?