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
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