Create a Custom Pie Chart #1 in Python


In this tutorial, you will learn to create a custom pie chart #1 in python. You only need to import matplotlib in this tutorial. The source code is show below.

import matplotlib.pyplot as plt

# Pie chart
labels = ['Production', 'Facilities', 'Insurance', 'Legal', 'Taxes', 'Licenses', 'Labor']
sizes = [35, 10, 18, 22, 15, 12, 28]

# only "explode" the 2nd slice (i.e. 'Hogs')
explode = (0.1, 0, 0, 0, 0, 0, 0)  
fig1, ax1 = plt.subplots()
ax1.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%',
        shadow=True, startangle=90)

# Equal aspect ratio ensures that pie is drawn as a circle
plt.title('Project Cost Breakdown')

The output you get will be:

Back To Top