Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created Nov 30, 2020
Embed
What would you like to do?
no_dup = df.drop_duplicates('Name')
g_count = no_dup['Genre'].value_counts()
fig, ax = plt.subplots(figsize=(8, 8))
def make_autopct(values):
def my_autopct(pct):
total = sum(values)
val = int(round(pct*total/100.0))
return '{p:.2f}%\n({v:d})'.format(p=pct,v=val)
return my_autopct
genre_col = ['navy','crimson']
#genre_col = ['khaki','plum']
center_circle = plt.Circle((0, 0), 0.7, color='white')
plt.pie(x=g_count.values, labels=g_count.index, autopct=make_autopct(g_count.values),
startangle=90, textprops={'size': 15}, pctdistance=0.5, colors=genre_col)
ax.add_artist(center_circle)
fig.suptitle('Distribution of Genre for all unique books from 2009 to 2019', fontsize=20)
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment