Create Custom Pie Chart #3 in Python


In this tutorial, you will learn to create custom pie chart #3 in python. First, you need to import matplotlib in order to continue this tutorial. The source code is show below.

import matplotlib.pyplot as plt
# Pie chart
labels = ['Frogs', 'Hogs', 'Dogs', 'Logs']
sizes = [15, 30, 45, 10]
colors = ['#ff9999','#66b3ff','#99ff99','#ffcc99']
explode = (0.05,0.05,0.05,0.05)
plt.pie(sizes, colors = colors, labels=labels, autopct='%1.1f%%', startangle=90, pctdistance=0.85, explode = explode)
#draw circle
centre_circle = plt.Circle((0,0),0.70,fc='white')
fig = plt.gcf()
# Equal aspect ratio ensures that pie is drawn as a circle

The output you get will be:

Back To Top