Search
 
SCRIPT & CODE EXAMPLE
 

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()
Comment

PREVIOUS NEXT
Code Example
Python :: set django static root 
Python :: tensorflow version check 
Python :: how to talk to girls 
Python :: matplotlib xticks font size 
Python :: make tkinter btn disable 
Python :: python text tkinter not typable 
Python :: how to make a hidden file in python 
Python :: install streamlit 
Python :: split data validation 
Python :: how to save and load model in keras 
Python :: Creating an admin user in django terminal 
Python :: python toast notification 
Python :: set axis labels python 
Python :: replace all spacec column with underscore in pandas 
Python :: python hide console 
Python :: python simple server 
Python :: plt to png python 
Python :: python reload function in shell 
Python :: export dataframe to csv python 
Python :: update python ubuntu 
Python :: python get day name 
Python :: python save seaborn plot 
Python :: get pytorch version 
Python :: download python on wsl 
Python :: dataframe find nan rows 
Python :: python write to json with indent 
Python :: matplotlib get rid of gridlines 
Python :: how clear everything on canvas in tkinter 
Python :: path sum with python 
Python :: python shebang line 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =