Skip to content

Instantly share code, notes, and snippets.

@Padhma
Created July 9, 2021 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Padhma/5196f7baf5b40dc08cb0ffc1e69a1509 to your computer and use it in GitHub Desktop.
Save Padhma/5196f7baf5b40dc08cb0ffc1e69a1509 to your computer and use it in GitHub Desktop.
# length of tags list in each column
len_tags = [len(tag) for tag in topic_tags]
# create a new column -> total_tags
github_df['Total_Tags'] = len_tags
# group based on topic and calculate total_tags in each topic
topic_wise_tags = github_df.groupby('Topic').sum()['Total_Tags'].reset_index(name='Total Tags')
# set figure size and dpi
fig, ax = plt.subplots(figsize=(7,4), dpi=100)
# remove background grids
ax.grid(False)
ax.set_facecolor('white')
sns.despine()
# plot the data
sns.barplot(data=topic_wise_tags,x='Total Tags', y='Topic', ci=None, palette='gist_rainbow');
# set x and y-axis labels and title
ax.set_xlabel('Total Tags', fontsize=13, color = '#333F4B')
ax.set_ylabel('Topic', fontsize=13, color = '#333F4B')
fig.suptitle('Tags distribution across topics',fontsize=18, color = '#333F4B');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment