Skip to content

Instantly share code, notes, and snippets.

@sadimanna
Created July 30, 2021 17:59
Show Gist options
  • Save sadimanna/e6497017e16a160d76c07534535ed463 to your computer and use it in GitHub Desktop.
Save sadimanna/e6497017e16a160d76c07534535ed463 to your computer and use it in GitHub Desktop.
fig,ax = plt.subplots(1,1, figsize=(10,10))
b = []
for i in range(num_plyrs):
b.append(ax.bar(x - (i - num_plyrs/2 + 0.5)*w,
stats.loc[i].values[1:],
width=w,
color=colors(i),
align='center',
edgecolor = 'black',
linewidth = 1.0,
alpha=0.5))
ax.legend([b_ for b_ in b],
stats['Players'].values.tolist(),
ncol = 3,
loc = 'best',
framealpha = 0.1)
ax.set_ylabel('Goals')
ax.set_xlabel('Players')
ax.set_title('Goals Scored by Players')
ax.set_xticks(x)
ax.set_xticklabels(stats.columns.values[1:])
for i in range(num_plyrs):
ax.bar_label(b[i],
padding = 3,
label_type='center',
rotation = 'vertical')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment