-
-
Save davidbradway/2732b387419f23a7d6422cd09e8b9320 to your computer and use it in GitHub Desktop.
This file contains 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 pandas as pd | |
import matplotlib.pyplot as plt | |
# Import Data | |
data = pd.read_csv('scrubbed.csv') | |
data.head() | |
#Prepare "shapes" column for donut plot entry | |
shapes = data['shape'].value_counts(normalize=True) * 100 | |
Keys = shapes.keys().to_list() | |
Percent = shapes.to_list() | |
fig = plt.figure(figsize=(20,20)) # Create matplotlib figure | |
plt.rcParams.update({'font.size': 40, 'font.family': 'monospace'}) | |
labels = Keys | |
sizes = Percent | |
colors = ['steelblue', 'lightseagreen', 'lightslategrey', 'teal', 'lavender', 'honeydew', 'darkseagreen', 'mediumaquamarine', 'paleturquoise', 'skyblue', 'thistle', 'plum', 'orchid', 'slateblue', 'dimgray', 'lightgrey', 'mediumpurple'] | |
# Plot Pie Chart | |
plt.pie(sizes, | |
colors=colors, | |
labels=labels, | |
autopct='%1.1f%%', | |
shadow=False) | |
# circle at the center of pie to make it look like a donut | |
centre_circle = plt.Circle((0,0),0.65,color='white', 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() | |
#Save figure | |
plt.savefig(('donut.png')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment