Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to add percentage in pie chart in python

# you can add percentage in matplotlib pie chart by using autopct parameter
data = [value1, value2, value3, ...]
labels = ['label1', 'label2', 'label3', ...]

#define Seaborn color palette to use
colors = sns.color_palette('pastel')[0:5]

#create pie chart
plt.pie(data, labels = labels, colors = colors, autopct='%.0f%%')
#                                                 ↑_ add this parameter for %
plt.show()
 
PREVIOUS NEXT
Tagged: #add #percentage #pie #chart #python
ADD COMMENT
Topic
Name
5+8 =