Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created November 30, 2020 07:41
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save amankharwal/39e8303cfccc239a672dbae6a318cd56 to your computer and use it in GitHub Desktop.
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