Guest User

Untitled

a guest
Jun 18th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #make the simple dataframe
  2. married = ['M', "NO DATA", 'S']
  3. percentage = [68.7564554, 9.35558, 21.8879646]
  4. df = pd.DataFrame(married, percentage)
  5. df.reset_index(level=0, inplace=True)
  6. df.columns = ['percentage', 'married']
  7.  
  8. #make the bar plot
  9. sns.barplot(x = 'married', y = 'percentage', data = df)
  10. plt.title('title')
  11. plt.xlabel('married')
  12. plt.ylabel('Percentage')
  13.  
  14. #place the labels
  15. ax = plt.gca()
  16. y_max = df['percentage'].value_counts().max()
  17. ax.set_ylim(1)
  18. for p in ax.patches:
  19. ax.text(p.get_x() + p.get_width()/2., p.get_height(), '%d' %
  20. int(p.get_height()),
  21. fontsize=12, color='red', ha='center', va='bottom')
Add Comment
Please, Sign In to add comment