Matplotlib > Pie charts

Name
Code
Output
labels = ['A','B','C','D']
shares = [10,20,30,40] 
matplotlib.pyplot.pie(shares,labels=labels)
matplotlib.pyplot.show()

       
           Pie chart (basic)
       
    
labels = ['A','B','C','D']
shares = [10,20,30,20] 
# Data
gaussian = numpy.random.normal(loc=1.0, scale=0.1,size = 10000)
# New Figure
fig = matplotlib.pyplot.figure(figsize=(7,4),facecolor='azure')
# New Axes
ax = fig.add_subplot(111)
# Plot the data
ax.pie(shares,explode=(0.2,0,0,0),labels=labels,
       colors=['red','green','orange','yellow'],
       autopct='%.0f%%',shadow=True,radius=0.9,counterclock=False)
ax.set(title="Plot title")
# Fit the plot layout
matplotlib.pyplot.tight_layout()
# Show the plot
matplotlib.pyplot.show()

       
           Pie chart (customized)