Created
September 11, 2015 11:56
-
-
Save krishnakummar/ad00d05311977732764f to your computer and use it in GitHub Desktop.
Donut chart using python matplotlib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
# The slices will be ordered and plotted counter-clockwise. | |
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' | |
sizes = [15, 30, 45, 10] | |
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral'] | |
explode = (0, 0, 0, 0) # explode a slice if required | |
plt.pie(sizes, explode=explode, labels=labels, colors=colors, | |
autopct='%1.1f%%', shadow=True) | |
#draw a circle at the center of pie to make it look like a donut | |
centre_circle = plt.Circle((0,0),0.75,color='black', fc='white',linewidth=1.25) | |
fig = plt.gcf() | |
fig.gca().add_artist(centre_circle) | |
# Set aspect ratio to be equal so that pie is drawn as a circle. | |
plt.axis('equal') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment