Answers for "how to add percentage in pie chart in python"

0

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()
Posted by: Guest on January-08-2022
0

pie auto percentage in python

plt.figure()
values = [3, 12, 5, 8] 
labels = ['a', 'b', 'c', 'd'] 
plt.pie(values, labels=labels) #autopct??
plt.show()
Posted by: Guest on December-02-2021

Python Answers by Framework

Browse Popular Code Answers by Language