Last active
August 31, 2019 14:14
-
-
Save FBosler/7e2d277038139933aefc454c61e4906c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def plot_bars(data,x_col,y_col): | |
data = data.reset_index() | |
sns.set( | |
font_scale=1.5, | |
style="whitegrid", | |
rc={'figure.figsize':(20,7)} | |
) | |
g = sns.barplot(x=x_col, y=y_col, data=data, color='royalblue') | |
for p in g.patches: | |
g.annotate( | |
format(p.get_height(), '.2%'), | |
(p.get_x() + p.get_width() / 2., p.get_height()), | |
ha = 'center', | |
va = 'center', | |
xytext = (0, 10), | |
textcoords = 'offset points' | |
) | |
vals = g.get_yticks() | |
g.set_yticklabels(['{:,.0f}%'.format(x*100) for x in vals]) | |
sns.despine() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment