In this short post, we look at how to create a pie chart as follows:

The key code blocks are as follows:
The function to compute the percentages:
def my_autopct(pct):
return ('%.2f' % pct)
The function to assign labels:
def get_new_labels(sizes, labels):
new_labels = [label for size, label in zip(sizes, labels)]
return new_labels
How do you show the labels only for the significant shares (especially if we have many entries in the bar chart)?