Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created November 30, 2020 07:43
  • 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
Embed
What would you like to do?
y1 = np.arange(2009, 2014)
y2 = np.arange(2014, 2020)
g_count = df['Genre'].value_counts()
fig, ax = plt.subplots(2, 6, figsize=(12,6))
ax[0,0].pie(x=g_count.values, labels=None, autopct='%1.1f%%',
startangle=90, textprops={'size': 12, 'color': 'white'},
pctdistance=0.5, radius=1.3, colors=genre_col)
ax[0,0].set_title('2009 - 2019\n(Overall)', color='darkgreen', fontdict={'fontsize': 15})
for i, year in enumerate(y1):
counts = df[df['Year'] == year]['Genre'].value_counts()
ax[0,i+1].set_title(year, color='darkred', fontdict={'fontsize': 15})
ax[0,i+1].pie(x=counts.values, labels=None, autopct='%1.1f%%',
startangle=90, textprops={'size': 12,'color': 'white'},
pctdistance=0.5, colors=genre_col, radius=1.1)
for i, year in enumerate(y2):
counts = df[df['Year'] == year]['Genre'].value_counts()
ax[1,i].pie(x=counts.values, labels=None, autopct='%1.1f%%',
startangle=90, textprops={'size': 12,'color': 'white'},
pctdistance=0.5, colors=genre_col, radius=1.1)
ax[1,i].set_title(year, color='darkred', fontdict={'fontsize': 15})
#plt.suptitle('Distribution of Fiction and Non-Fiction books for every year from 2009 to 2019',
#fontsize=25)
fig.legend(g_count.index, loc='center right', fontsize=12)
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment