Skip to content

Instantly share code, notes, and snippets.

@Kamaldeep0077
Created October 1, 2020 07:01
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 Kamaldeep0077/dde8880e1ab928993b475b183b305566 to your computer and use it in GitHub Desktop.
Save Kamaldeep0077/dde8880e1ab928993b475b183b305566 to your computer and use it in GitHub Desktop.
#Ploting barplot for target
plt.figure(figsize=(10,6))
g = sns.barplot(data['stroke'], data['stroke'], palette='Set1', estimator=lambda x: len(x) / len(data) )
#Anotating the graph
for p in g.patches:
width, height = p.get_width(), p.get_height()
x, y = p.get_xy()
g.text(x+width/2,
y+height,
'{:.0%}'.format(height),
horizontalalignment='center',fontsize=15)
#Setting the labels
plt.xlabel('Heart Stroke', fontsize=14)
plt.ylabel('Precentage', fontsize=14)
plt.title('Percentage of patients will/will not have heart stroke', fontsize=16)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment